public  string Encrypt(string str)
{
string result = null;
if (str == null)
{
return result;
}
try
{
byte[] array0 = Encoding.ASCII.GetBytes(str);
MemoryStream stream = new MemoryStream(array0);
RijndaelManaged rijndaelManaged = new RijndaelManaged();
byte[] key = new byte[] { , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , };
byte[] vi = new byte[] { , , , , , , , , , , , , , , , }; ICryptoTransform transform = rijndaelManaged.CreateEncryptor(key, vi);
CryptoStream cryptoStream = new CryptoStream(stream, transform, CryptoStreamMode.Write);
result = cryptoStream.ToString();
cryptoStream.FlushFinalBlock();
return result;
}
catch
{
return null;
}
} public string Decode(string str)
{
string result = null;
if (str == null)
{
return result;
} try
{
byte[] array0 = Encoding.ASCII.GetBytes(str);
MemoryStream stream = new MemoryStream(array0);
RijndaelManaged rijndaelManaged = new RijndaelManaged();
byte[] key = new byte[] { , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , };
byte[] vi = new byte[] { , , , , , , , , , , , , , , , }; ICryptoTransform transform = rijndaelManaged.CreateEncryptor(key, vi);
CryptoStream inStream = new CryptoStream(stream, transform, CryptoStreamMode.Read);
return inStream.ToString();
}
catch
{
return null;
}
}

1.代码中key和vi分别对应加密器对象Key和初始化向量 (IV)

2.Key和VI只有完全匹配得上加密数据才可以被解密

RijndaelManaged 加密的更多相关文章

  1. 数据加密之RijndaelManaged加密

    #region RijndaelManaged加密 /// <summary> /// 加密数据 /// </summary> /// <param name=" ...

  2. C#加密解密(DES,AES,Base64,md5,SHA256,RSA,RC4)

    一:异或^简单加解密(数字类型) 1:原理: 异或用于比较两个二进制数的相应位,在执行按位"异或"运算时,如果两个二进制数的相应位都为1或者都为0,则返回0;如果两个二进制数的相应 ...

  3. 。net加密解密相关方法

    AES加密及解密 声明密钥级偏移向量--------/// <summary> /// 加密密钥 /// </summary> private static readonly ...

  4. C#工具:加密解密帮助类

    using System; using System.IO; using System.Security.Cryptography; using System.Text; //加密字符串,注意strE ...

  5. Visual Studio 2017中使用正则修改部分内容 如何使用ILAsm与ILDasm修改.Net exe(dll)文件 C#学习-图解教程(1):格式化数字字符串 小程序开发之图片转Base64(C#、.Net) jquery遍历table为每一个单元格取值及赋值 。net加密解密相关方法 .net关于坐标之间一些简单操作

    Visual Studio 2017中使用正则修改部分内容   最近在项目中想实现一个小工具,需要根据类的属性<summary>的内容加上相应的[Description]特性,需要实现的效 ...

  6. C# 各种加密

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Sec ...

  7. unity3d-解密加密数据

    利用RijndaelManaged加密解码.需要导入命名空间 using System.Security.Cryptography; 一个很简单的例子,最终的结果 解密和加密类 public clas ...

  8. ASP.NET MVC5+EF6+EasyUI 后台管理系统(62)-EF链接串加密

    系列目录 前言: 这一节提供一个简单的功能,这个功能看似简单,找了一下没找到EF链接数据库串的加密帮助文档,只能自己写了,这样也更加符合自己的加密要求 有时候我们发布程序为了避免程序外的SQL链接串明 ...

  9. c#和js互通的AES加密解密

    一.使用场景 在使用前后端分离的框架中常常会进行传输数据相互加密解密以确保数据的安全性,如web Api返回加密数据客户端或web端进行解密,或者客户端或web端进行加密提交数据服务端解密数据等等. ...

随机推荐

  1. Bet(The 2016 ACM-ICPC Asia China-Final Contest 思路题)

    题目: The Codejamon game is on fire! Fans across the world are predicting and betting on which team wi ...

  2. [BOI2008]Elect 选举

    背包. #include <algorithm> #include <iostream> #include <cstdlib> #include <cstri ...

  3. oracle打开或者关闭flashback

    1.打开flashback: 关闭数据库 SQL>shutdown immediate; 启动到mount方式 SQL>startup mount; 如果归档没有打开,打开归档[因为fla ...

  4. JSP页面中的动作标识

    JSP页面中的动作标识 制作人:全心全意 包含文件标识<jsp:include> 此标识和include指令类似,用于向当前页面中包含其它的文件,且包含的文件可以是动态文件,也可以是静态文 ...

  5. Laravel5.5 综合使用

    使用 Laravel5.5 开发一个自动交割的项目,把使用到的开源扩展包及特性整理起来,以供后续使用. 一.安装IDE提示工具 Laravel IDE Helper 是一个极其好用的代码提示及补全工具 ...

  6. codechef营养题 第三弹

    第三弾が始まる! codechef problems 第三弹 一.Motorbike Racing 题面 It's time for the annual exciting Motorbike Rac ...

  7. 模拟select控件功能

    直接上代码 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  8. 实用型的DJANGO ORM

    比较深入一点的内容,需要用时,用心看看. URL: https://www.sitepoint.com/doing-more-with-your-django-models/ https://www. ...

  9. POJ 1523 SPF 割点 Tarjan

    SPF Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9317   Accepted: 4218 Description C ...

  10. 1. MissingInteger 最小遗失整数 Find the minimal positive integer not occurring in a given sequence.

    package com.code; import java.util.Arrays; public class Test04_1 { public static int solution(int[] ...