python system uses CFB8 (8 bit segments). Go does not support this out of the box.
good for me link
SEGMENT_SIZE=128 | |
BLOCK_SIZE = 16 | |
cipher = AES.new(KEY, AES.MODE_CFB, IV, segment_size=SEGMENT_SIZE) | |
dc = dynamic_token.decode("hex") | |
pt = cipher.decrypt(dc) | |
print pt |
func padString(data []byte) []byte { | |
padNum := len(data) % 16 | |
if padNum != 0 { | |
for i := 0; i < 16-padNum; i++ { | |
data = append(data, ',') | |
} | |
} | |
return data | |
} | |
func encodeCipherText(text string) string { | |
paddedText := padString([]byte(text)) | |
c, err := aes.NewCipher([]byte(SECRET_KEY)) | |
if err != nil { | |
fmt.Println(418) | |
} | |
cfb := cipher.NewCFBEncrypter(c, IV) | |
ciphertext := make([]byte, len(paddedText)) | |
cfb.XORKeyStream(ciphertext, paddedText) | |
fmt.Println(ciphertext) | |
return hex.EncodeToString(ciphertext[:]) | |
} | |