是使用AES或SHA256的sjcl.encrypt [英] is sjcl.encrypt using AES or SHA256

查看:365
本文介绍了是使用AES或SHA256的sjcl.encrypt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 SJCL库加密/解密邮件。我的问题是,我不知道哪一个使用AES或SHA256

I'm using the SJCL library to encrypt/decrypt messages. The question I have is that I don't know which is used AES or SHA256

这是我的代码:

var h = sjcl.codec.hex, count = 2048 ;
salt = h.fromBits(sjcl.random.randomWords('10','0'));
var key = h.fromBits( sjcl.misc.pbkdf2(somePassword, h.toBits(salt), count) ) ;

下一步我可以加密/解密像

Next I can encrypt/decrypt like

var encMessage = sjcl.encrypt(key, message) ;
sjcl.decrypt(key, encMessage) ;

AES或SHA256或其他东西?

AES or SHA256 or something else ?

推荐答案

pbkdf2 用于密钥生成是使用 HMAC SHA256 。但是对于 AES-CCM 的sjcl的默认加密密钥大小只有 128 位。如果您想要 AES-CCM-256 ,我想您需要执行以下操作,您也不必调用 pbkdf2 直接。

pbkdf2 for key generation is using HMAC with SHA256. But the default encryption key size with sjcl for AES-CCM is only 128 bits. If you want AES-CCM-256, I think you need to do the following, you also don't have to call pbkdf2 directly.

var encMessage =sjcl.encrypt(somePassword,message,{count:2048,salt:salt,ks:256});

这篇关于是使用AES或SHA256的sjcl.encrypt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆