crypto
crypto copied to clipboard
Why my AES result wrong?
My typescript AES result is different from golang language, typescript is client language, and golang is my server language.
Then I try some AES website like https://the-x.cn/en-US/cryptography/Aes.aspx, and I found golang AES result is same as the website AES result.
Here is my code.
const te = new TextEncoder();
const key = te.encode("1234567899999999");
const data = te.encode("1234");
const iv = new Uint8Array(16)
for (let i = 0; i < key.length; i++) {
iv[i] = key[i]
}
const cipher = new Cbc(Aes, key, iv, Padding.PKCS7);
const encrypted = cipher.encrypt(data);
const base64 = Base64.encode(encrypted)
The typescript AES result = CbV6UFL7HC7H1smYlwliVg== The golang AES result = S7gxtGIbOdtmzhn4vAW13A== The website AES result = S7gxtGIbOdtmzhn4vAW13A==
It's so strange and I am checking my code, does my code has any problem?