Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If the length of iv is less than 16, how does 'crypto-js' pad it (make the iv length expanded to the length of 16) #487

Open
ZHAO-Clara opened this issue Mar 29, 2024 · 1 comment

Comments

@ZHAO-Clara
Copy link

ZHAO-Clara commented Mar 29, 2024

If the length of iv is less than 16, how does 'crypto-js' pad it (make the iv length expanded to the length of 16)?

for example i use the following code, what is the ’iv‘ actually used during the encryption process?
like '432100000000'?

const CryptoJS = require('crypto-js')
const key = CryptoJS.enc.Utf8.parse('12345678ABCD')
const iv = CryptoJS.enc.Utf8.parse('4321')
let srcs = CryptoJS.enc.Utf8.parse(word)
let encrypted = CryptoJS.AES.encrypt(srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 })

Thank you so much

@ZHAO-Clara ZHAO-Clara changed the title If the length of iv is less than 12, how does 'crypto-js' pad it (make the iv length expanded to the length of 12) If the length of iv is less than 16, how does 'crypto-js' pad it (make the iv length expanded to the length of 16) Apr 1, 2024
@ZHAO-Clara
Copy link
Author

I have the answer. Actually it uses the "null" in ascii to pad iv, in other words, 0x00 in Hex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant