go - Encryption of AES(128/ECB/PKCS5)+Base64(RFC 1521) in Java and decryption in Golang -


the encryption in java importing javax.crypto.cipher, sun.misc.base64decoder, sun.misc.base64encoder , javax/crypto/secretkey.

i did lot research on algorithms understand specific standards make sure every step same in java , golang.

since cannot decrypt encrypted data java, trying see difference encrypting in golang , in java see difference. encrypted outputs golang , java different w/ same format(24 digits "=="at end).

 inputs: key: t3-arghbegrgg455dfer4g==           text: 123456789012345   output: golang: 07vl02wwi8dapjyi161trq==           java:   b9e8aocd+fyqbkkbqcs3la==   

please find out reason behind difference! thanks!

the java code using

cipher cipher = cipher.getinstance("aes"); cipher.init(cipher.encrypt_mode, secretkey);  byte[] stringbytes = message.getbytes("utf8"); byte[] raw = cipher.dofinal(stringbytes);  base64encoder encoder = new base64encoder(); string base64 = encoder.encode(raw); return base64; 

in golang

block, err := aes.newcipher(key) if err != nil {     return "",err } content := []byte(src) ecb := newecbencrypter(block) content = pkcs5padding(content, block.blocksize()) crypted := make([]byte, len(content)) ecb.cryptblocks(crypted, content) finalmsg := base64.stdencoding.encodetostring(crypted) return finalmsg,nil 


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -