AES Encryption Output Hex vb.net -
i figured pretty straight forward have issue getting aes encryption function return hex string. can work when convert base64 cannot string hex values. here code. appreciated.
dim aes_encryption new system.security.cryptography.rijndaelmanaged dim code_aes new system.security.cryptography.md5cryptoserviceprovider dim encrypted string = "" try dim hash(31) byte dim temp byte() = code_aes.computehash(system.text.asciiencoding.ascii.getbytes(pass)) array.copy(temp, 0, hash, 0, 16) array.copy(temp, 0, hash, 15, 16) aes_encryption.key = hash aes_encryption.mode = ciphermode.ecb dim aes_encryptor system.security.cryptography.icryptotransform = aes_encryption.createencryptor dim buffer byte() = system.text.asciiencoding.ascii.getbytes(input) encrypted = (conversion.hex(aes_encryptor.transformfinalblock(buffer, 0, buffer.length))) catch ex exception end try return encrypted
i've tried example, , i've got nothing either.
so tried instead of having encrypted = (conversion.hex(aes_encryptor.transformfinalblock(buffer, 0, buffer.length)))
, have used loop convert each byte hex equivalent, , concatenate encrypted
.
dim encrypted_byte() byte = aes_encryptor.transformfinalblock(buffer, 0, buffer.length) integer = 0 encrypted_byte.length - 1 encrypted = encrypted & hex(encrypted_byte(i)).toupper next
i'm not sure how formatted hex string in java, should @ least start.
Comments
Post a Comment