为什么人们使用bouncycastle而不是Java Cryptography Extension?有什么不同?
如何将散列结果(字节数组)转换为字符串?
byte[] bytePassword = Encoding.UTF8.GetBytes(password);
using (MD5 md5 = MD5.Create())
{
byte[] byteHashedPassword = md5.ComputeHash(bytePassword);
}
Run Code Online (Sandbox Code Playgroud)
我需要转换byteHashedPassword为字符串.
使用Rfc2898DeriveBytes和使用之间有什么区别Encoding.ASCII.GetBytes(string object);?
我对这两种方法都取得了相对的成功,前者是一种更长时间的方法,因为后者很简单而且非常重要.两者似乎都允许你最终做同样的事情,但我正在努力看到使用前者而不是后者.
我能够掌握的基本概念是你可以将字符串密码转换为字节数组,用于例如对称加密类AesManaged.通过RFC类,但在创建rfc对象时可以使用salt值和密码.我认为它更安全,但仍然是一个没有受过教育的猜测!此外,它允许您返回一定大小的字节数组,就像这样.
以下是一些示例,向您展示我的来源:
byte[] myPassinBytes = Encoding.ASCII.GetBytes("some password");
Run Code Online (Sandbox Code Playgroud)
要么
string password = "P@%5w0r]>";
byte[] saltArray = Encoding.ASCII.GetBytes("this is my salt");
Rfc2898DeriveBytes rfcKey = new Rfc2898DeriveBytes(password, saltArray);
Run Code Online (Sandbox Code Playgroud)
'rfcKey'对象现在可用于在对称加密算法类上设置.Key或.IV属性.
即.
RijndaelManaged rj = new RijndaelManaged ();
rj.Key = rfcKey.Getbytes(rj.KeySize / 8);
rj.IV = rfcKey.Getbytes(rj.Blocksize / 8);
Run Code Online (Sandbox Code Playgroud)
'rj'应该准备好了!
令人困惑的部分......所以我不是只使用'myPassInBytes'数组来帮助设置我的'rj'对象,而不是使用'rfcKey'对象?
我试过在VS2008中这样做,直接答案是否定的.但是,你们有一个更好的教育答案,为什么RFC类被用于上面提到的另一种选择?
如何使用OpenSSL库生成SHA1或SHA2哈希?
我搜索谷歌,找不到任何功能或示例代码.
我正在使用CryptEncryptMessage生成PKCS#7包络消息.我szOID_NIST_AES256_CBC用作加密算法.
生成的消息似乎是有效的,但是RSAES-OAEP密钥传输算法在野外具有有限的支持(Thunderbird,OpenSSL SMIME模块和许多其他人不支持它).
我希望CAPI能够恢复到旧版RSAencryption的密钥传输.
有没有可能的方法,如果有一种方法而不是使用我可以恢复到低级消息传递功能,CryptEncryptMessage但即使使用低级函数我也找不到办法.
码:
CRYPT_ENCRYPT_MESSAGE_PARA EncryptMessageParams;
EncryptMessageParams.cbSize = sizeof(CMSG_ENVELOPED_ENCODE_INFO);
EncryptMessageParams.dwMsgEncodingType = PKCS_7_ASN_ENCODING;
EncryptMessageParams.ContentEncryptionAlgorithm.pszObjId = szOID_NIST_AES256_CBC;
EncryptMessageParams.ContentEncryptionAlgorithm.Parameters.cbData = 0;
EncryptMessageParams.ContentEncryptionAlgorithm.Parameters.pbData = 0;
EncryptMessageParams.hCryptProv = NULL;
EncryptMessageParams.pvEncryptionAuxInfo = NULL;
EncryptMessageParams.dwFlags = 0;
EncryptMessageParams.dwInnerContentType = 0;
BYTE pbEncryptedBlob[640000];
DWORD pcbEncryptedBlob = 640000;
BOOL retval = CryptEncryptMessage(&EncryptMessageParams, cRecipientCert, pRecipCertContextArray, pbMsgText, dwMsgTextSize, pbEncryptedBlob, &pcbEncryptedBlob);
Run Code Online (Sandbox Code Playgroud) 我正在寻找一些如何使用node.js和mongodb安全地存储密码和其他敏感数据的示例.
我希望一切都使用一个独特的盐,我将存储在mongo文档中的哈希旁边.
对于身份验证,我是否只需对输入进行加密和加密,并将其与存储的哈希相匹配?
我是否需要解密此数据?如果需要,我应该如何解决?
如何将私钥,甚至salting方法安全地存储在服务器上?
我听说AES和Blowfish都是不错的选择,我该怎么用?
任何如何设计这个的例子都会非常有用!
谢谢!
我的ubuntu是14.04 LTS.
当我安装加密时,错误是:
Installing egg-scripts.
uses namespace packages but the distribution does not require setuptools.
Getting distribution for 'cryptography==0.2.1'.
no previously-included directories found matching 'documentation/_build'
zip_safe flag not set; analyzing archive contents...
six: module references __path__
Installed /tmp/easy_install-oUz7ei/cryptography-0.2.1/.eggs/six-1.10.0-py2.7.egg
Searching for cffi>=0.8
Reading https://pypi.python.org/simple/cffi/
Best match: cffi 1.5.0
Downloading https://pypi.python.org/packages/source/c/cffi/cffi-1.5.0.tar.gz#md5=dec8441e67880494ee881305059af656
Processing cffi-1.5.0.tar.gz
Writing /tmp/easy_install-oUz7ei/cryptography-0.2.1/temp/easy_install-Yf2Yl3/cffi-1.5.0/setup.cfg
Running cffi-1.5.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-oUz7ei/cryptography-0.2.1/temp/easy_install-Yf2Yl3/cffi-1.5.0/egg-dist-tmp-A2kjMD
c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^
compilation terminated.
error: Setup script exited with error: command …Run Code Online (Sandbox Code Playgroud) 我理解标准随机数生成器如何工作.但是当使用crytpography时,随机数确实必须是随机的.
我知道有些仪器可以读取宇宙白噪声以帮助产生安全的哈希值,但是你的标准PC没有这个.
加密安全随机数生成器如何在没有可重复模式的情况下获取其值?
我一直在阅读/dev/urandom,据我所知,/dev/random通过利用网络数据包时序等几个事件来创建加密随机数.但是,我是否理解/dev/urandom使用PRNG,播种数字来自/dev/random?或者/dev/random只要有比特就可以使用它- 当它们用尽时它会回到一些PRNG,从那里收集种子?