zoukankan      html  css  js  c++  java
  • C# 加密-Rijndael

    Rijndael 属对称加密,对称加密在加密和解密时都使用相同的密钥。2000 年 10 月,NIST 选择 Rijndael(发音为 "Rhine dale")作为 AES 算法,用以取代 DES。

    Rijndael 的名称空间是:

    System.Security.Cryptography
    byte[] plaintextBuffer = System.Text.Encoding.UTF8.GetBytes("明文");

    //加密
    Rijndael rijndael = Rijndael.Create();
    ICryptoTransform transform = rijndael.CreateEncryptor();
    byte[] cipherTextBuffer = transform.TransformFinalBlock(plaintextBuffer, 0, plaintextBuffer.Length);
    lbl.Text = Convert.ToBase64String(cipherTextBuffer) + "<br />";
    transform.Dispose();

    //解密
    Rijndael rijndael2 = Rijndael.Create();
    ICryptoTransform transform2 = rijndael2.CreateDecryptor(rijndael.Key, rijndael.IV);
    byte[] decryption = transform2.TransformFinalBlock(cipherTextBuffer, 0, cipherTextBuffer.Length);
    lbl.Text += System.Text.Encoding.UTF8.GetString(decryption) + "<br />";
    transform2.Dispose();

    解密时,使用加密的 Key 和 IV。

  • 相关阅读:
    Mybatis源码中最重要的几个类
    学习爬虫-运营商积分
    IntelliJ IDEA 最新版 2019.2.4 激活 (持续更新)(含windows和Mac)
    归并排序之求小和
    归并排序
    理解递归
    插入排序
    对数器
    冒泡排序
    mysql 数据库名称,中间带有中划线问题
  • 原文地址:https://www.cnblogs.com/ghfsusan/p/1613576.html
Copyright © 2011-2022 走看看