cryptojs: How to generate AES passphrase

后端 未结 2 1597

I want to generate a 256bit password for my AES encryption. When I check the password after the encryption it is different from my initial password. What am I doing wrong? Or i

2条回答
  •  你的背包
    2021-02-15 19:04

    Encryption is done with a key, which is a set of binary bits, not a password, which implies a human-readable string.

    To go from a password to a key, one can use a Password Based Key Derivation Function, such as PBKDF2. Crypto-JS already has a PBKDF2 function built-in, i.e.

    
    
    

    In general, use as high an iteration count as you can get away with.

    Salt should be a random value, as in the example above; you'll need, of course, to store that value along with the iteration count in order to get the same key given the same passphrase.

提交回复
热议问题