小编Ani*_*kar的帖子

使用 Java 的 AES-256-GCM 解密中的标签不匹配错误

我用 Javascript 编写了以下函数,用于使用 aes-256-gcm 进行加密:

encrypt: function (text, masterkey){
    try {
        // random initialization vector
        var iv = crypto.randomBytes(12);

        // random salt
        var salt = crypto.randomBytes(64);

        // derive key: 32 byte key length - in assumption the masterkey is a cryptographic and NOT a password there is no need for
        // a large number of iterations. It may can replaced by HKDF
        var key = crypto.pbkdf2Sync(masterkey, salt, 2145, 32, 'sha512');

        // AES 256 GCM Mode
        var cipher = crypto.createCipheriv('aes-256-gcm', key, …
Run Code Online (Sandbox Code Playgroud)

javascript java cryptography aes-gcm

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

aes-gcm ×1

cryptography ×1

java ×1

javascript ×1