与安全密钥C#DES编码密钥、安全、DES

由网友(你懂我的爱)分享简介:我知道这是一个可能是共同的问题,但我无法找到答案的任何地方。所以,我有字节数组键和字节数组值,我需要制作已在C#中被加密的DES新的8字节数组I know It's a probably common question but I cannot find answer anywhere. So I have byte...

我知道这是一个可能是共同的问题,但我无法找到答案的任何地方。所以,我有字节数组键和字节数组值,我需要制作已在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();
    }
阅读全文

相关推荐

最新文章