-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
i want to know how aes create key and iv from salt and passphrase #502
Comments
@fancy45daddy were you able to figure this out |
How come you’re doing that ?Sent from my iPhoneOn Sep 24, 2024, at 3:51 AM, nikhiltekwani09 ***@***.***> wrote:
@fancy45daddy were you able to figure this out
I also want the same information to write the code in native module
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
I m not sure right now, till I have the complete information which @fancy45daddy is requesting |
I am trying to decrypt encrypted content using a backend in a different language, and I solved this problem today. When you enter the Secret Passphrase, crypto-js consistently uses AES-256-CBC for encryption. |
that works~ very appreciated! |
from the doc var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase");
encrypted.key
i have no idea how to get key and iv, then i ask chatgpt, it give me some code
// Define passphrase and salt
const passphrase = 'your-passphrase';
const salt = CryptoJS.enc.Hex.parse('your-salt-in-hex'); // Salt should be in a suitable format
// Derive key and IV using PBKDF2
const keySize = 256 / 32; // Key size in words
const ivSize = 128 / 32; // IV size in words
const iterations = 1000; // Number of iterations
// Derive key
const key = CryptoJS.PBKDF2(passphrase, salt, {
keySize: keySize + ivSize, // Total size for key and IV
iterations: iterations
});
// Extract key and IV
const derivedKey = CryptoJS.lib.WordArray.create(key.words.slice(0, keySize)); // Extract key
const iv = CryptoJS.lib.WordArray.create(key.words.slice(keySize)); // Extract IV
but when i input the passphrase and salt in chatgpt code. it does not create the same key as that in encrypted.key and encrypted.iv. plèase help me to understand how to get key and iv
The text was updated successfully, but these errors were encountered: