与安全密钥C#DES编码 [英] DES encoding with security key C#
本文介绍了与安全密钥C#DES编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这是一个可能是共同的问题,但我无法找到答案的任何地方。所以,我有字节数组键和字节数组值,我需要制作已在C#中被加密的DES新的8字节数组
I know It's a probably common question but I cannot find answer anywhere. So I have byte array key and byte array value and I need to produce new 8 byte array that has been encrypted with DES in C#
推荐答案
这就是我一直在寻找:D:D ...谢谢:D
This is what I was looking for :D:D...thank you :D
private static byte[] Encrypt(byte[] value, byte[] key)
{
DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider
{
Mode = CipherMode.ECB,
Padding = PaddingMode.None
};
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoProvider.CreateEncryptor(key, key), CryptoStreamMode.Write);
cryptoStream.Write(value, 0, value.Length);
cryptoStream.Close();
return memoryStream.ToArray();
}
这篇关于与安全密钥C#DES编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文