当前位置: 首页>>代码示例>>C#>>正文


C# RijndaelManaged.TransformFinalBlock方法代码示例

本文整理汇总了C#中System.Security.Cryptography.RijndaelManaged.TransformFinalBlock方法的典型用法代码示例。如果您正苦于以下问题:C# RijndaelManaged.TransformFinalBlock方法的具体用法?C# RijndaelManaged.TransformFinalBlock怎么用?C# RijndaelManaged.TransformFinalBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.Cryptography.RijndaelManaged的用法示例。


在下文中一共展示了RijndaelManaged.TransformFinalBlock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AESKeyWrapDecrypt

 internal static byte[] AESKeyWrapDecrypt(byte[] rgbKey, byte[] rgbEncryptedWrappedKeyData)
 {
     int num = (rgbEncryptedWrappedKeyData.Length >> 3) - 1;
     if (((rgbEncryptedWrappedKeyData.Length % 8) != 0) || (num <= 0))
     {
         throw new CryptographicException(SecurityResources.GetResourceString("Cryptography_Xml_KW_BadKeySize"));
     }
     byte[] dst = new byte[num << 3];
     ICryptoTransform transform = new RijndaelManaged { Key = rgbKey, Mode = CipherMode.ECB, Padding = PaddingMode.None }.CreateDecryptor();
     if (num == 1)
     {
         byte[] src = transform.TransformFinalBlock(rgbEncryptedWrappedKeyData, 0, rgbEncryptedWrappedKeyData.Length);
         for (int k = 0; k < 8; k++)
         {
             if (src[k] != s_rgbAES_KW_IV[k])
             {
                 throw new CryptographicException(SecurityResources.GetResourceString("Cryptography_Xml_BadWrappedKeySize"));
             }
         }
         Buffer.BlockCopy(src, 8, dst, 0, 8);
         return dst;
     }
     long num3 = 0L;
     Buffer.BlockCopy(rgbEncryptedWrappedKeyData, 8, dst, 0, dst.Length);
     byte[] buffer3 = new byte[8];
     byte[] buffer4 = new byte[0x10];
     Buffer.BlockCopy(rgbEncryptedWrappedKeyData, 0, buffer3, 0, 8);
     for (int i = 5; i >= 0; i--)
     {
         for (int m = num; m >= 1; m--)
         {
             num3 = m + (i * num);
             for (int n = 0; n < 8; n++)
             {
                 byte num7 = (byte) ((num3 >> (8 * (7 - n))) & 0xffL);
                 buffer3[n] = (byte) (buffer3[n] ^ num7);
             }
             Buffer.BlockCopy(buffer3, 0, buffer4, 0, 8);
             Buffer.BlockCopy(dst, 8 * (m - 1), buffer4, 8, 8);
             byte[] buffer5 = transform.TransformFinalBlock(buffer4, 0, 0x10);
             Buffer.BlockCopy(buffer5, 8, dst, 8 * (m - 1), 8);
             Buffer.BlockCopy(buffer5, 0, buffer3, 0, 8);
         }
     }
     for (int j = 0; j < 8; j++)
     {
         if (buffer3[j] != s_rgbAES_KW_IV[j])
         {
             throw new CryptographicException(SecurityResources.GetResourceString("Cryptography_Xml_BadWrappedKeySize"));
         }
     }
     return dst;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:53,代码来源:SymmetricKeyWrap.cs

示例2: AES_Encrypt

 public static string AES_Encrypt(string encryptString, string encryptKey)
 {
     encryptKey = smethod_0(encryptKey, 0x20, "");
     encryptKey = encryptKey.PadRight(0x20, ' ');
     ICryptoTransform transform = new RijndaelManaged { Key = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 0x20)), IV = byte_0 }.CreateEncryptor();
     byte[] bytes = Encoding.UTF8.GetBytes(encryptString);
     return Convert.ToBase64String(transform.TransformFinalBlock(bytes, 0, bytes.Length));
 }
开发者ID:windygu,项目名称:asxinyunet,代码行数:8,代码来源:EncodeHelper.cs

示例3: AES_Decrypt

 public static string AES_Decrypt(string decryptString, string decryptKey)
 {
     try
     {
         decryptKey = smethod_0(decryptKey, 0x20, "");
         decryptKey = decryptKey.PadRight(0x20, ' ');
         ICryptoTransform transform = new RijndaelManaged { Key = Encoding.UTF8.GetBytes(decryptKey), IV = byte_0 }.CreateDecryptor();
         byte[] inputBuffer = Convert.FromBase64String(decryptString);
         byte[] bytes = transform.TransformFinalBlock(inputBuffer, 0, inputBuffer.Length);
         return Encoding.UTF8.GetString(bytes);
     }
     catch
     {
         return string.Empty;
     }
 }
开发者ID:windygu,项目名称:asxinyunet,代码行数:16,代码来源:EncodeHelper.cs

示例4: AESKeyWrapEncrypt

 internal static byte[] AESKeyWrapEncrypt(byte[] rgbKey, byte[] rgbWrappedKeyData)
 {
     int num = rgbWrappedKeyData.Length >> 3;
     if (((rgbWrappedKeyData.Length % 8) != 0) || (num <= 0))
     {
         throw new CryptographicException(SecurityResources.GetResourceString("Cryptography_Xml_KW_BadKeySize"));
     }
     ICryptoTransform transform = new RijndaelManaged { Key = rgbKey, Mode = CipherMode.ECB, Padding = PaddingMode.None }.CreateEncryptor();
     if (num == 1)
     {
         byte[] buffer = new byte[s_rgbAES_KW_IV.Length + rgbWrappedKeyData.Length];
         Buffer.BlockCopy(s_rgbAES_KW_IV, 0, buffer, 0, s_rgbAES_KW_IV.Length);
         Buffer.BlockCopy(rgbWrappedKeyData, 0, buffer, s_rgbAES_KW_IV.Length, rgbWrappedKeyData.Length);
         return transform.TransformFinalBlock(buffer, 0, buffer.Length);
     }
     long num2 = 0L;
     byte[] dst = new byte[(num + 1) << 3];
     Buffer.BlockCopy(rgbWrappedKeyData, 0, dst, 8, rgbWrappedKeyData.Length);
     byte[] buffer3 = new byte[8];
     byte[] buffer4 = new byte[0x10];
     Buffer.BlockCopy(s_rgbAES_KW_IV, 0, buffer3, 0, 8);
     for (int i = 0; i <= 5; i++)
     {
         for (int j = 1; j <= num; j++)
         {
             num2 = j + (i * num);
             Buffer.BlockCopy(buffer3, 0, buffer4, 0, 8);
             Buffer.BlockCopy(dst, 8 * j, buffer4, 8, 8);
             byte[] src = transform.TransformFinalBlock(buffer4, 0, 0x10);
             for (int k = 0; k < 8; k++)
             {
                 byte num6 = (byte) ((num2 >> (8 * (7 - k))) & 0xffL);
                 buffer3[k] = (byte) (num6 ^ src[k]);
             }
             Buffer.BlockCopy(src, 8, dst, 8 * j, 8);
         }
     }
     Buffer.BlockCopy(buffer3, 0, dst, 0, 8);
     return dst;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:40,代码来源:SymmetricKeyWrap.cs


注:本文中的System.Security.Cryptography.RijndaelManaged.TransformFinalBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。