RijndaelManaged 加密
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 加密的更多相关文章
- 数据加密之RijndaelManaged加密
#region RijndaelManaged加密 /// <summary> /// 加密数据 /// </summary> /// <param name=" ...
- C#加密解密(DES,AES,Base64,md5,SHA256,RSA,RC4)
一:异或^简单加解密(数字类型) 1:原理: 异或用于比较两个二进制数的相应位,在执行按位"异或"运算时,如果两个二进制数的相应位都为1或者都为0,则返回0;如果两个二进制数的相应 ...
- 。net加密解密相关方法
AES加密及解密 声明密钥级偏移向量--------/// <summary> /// 加密密钥 /// </summary> private static readonly ...
- C#工具:加密解密帮助类
using System; using System.IO; using System.Security.Cryptography; using System.Text; //加密字符串,注意strE ...
- Visual Studio 2017中使用正则修改部分内容 如何使用ILAsm与ILDasm修改.Net exe(dll)文件 C#学习-图解教程(1):格式化数字字符串 小程序开发之图片转Base64(C#、.Net) jquery遍历table为每一个单元格取值及赋值 。net加密解密相关方法 .net关于坐标之间一些简单操作
Visual Studio 2017中使用正则修改部分内容 最近在项目中想实现一个小工具,需要根据类的属性<summary>的内容加上相应的[Description]特性,需要实现的效 ...
- C# 各种加密
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Sec ...
- unity3d-解密加密数据
利用RijndaelManaged加密解码.需要导入命名空间 using System.Security.Cryptography; 一个很简单的例子,最终的结果 解密和加密类 public clas ...
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(62)-EF链接串加密
系列目录 前言: 这一节提供一个简单的功能,这个功能看似简单,找了一下没找到EF链接数据库串的加密帮助文档,只能自己写了,这样也更加符合自己的加密要求 有时候我们发布程序为了避免程序外的SQL链接串明 ...
- c#和js互通的AES加密解密
一.使用场景 在使用前后端分离的框架中常常会进行传输数据相互加密解密以确保数据的安全性,如web Api返回加密数据客户端或web端进行解密,或者客户端或web端进行加密提交数据服务端解密数据等等. ...
随机推荐
- PrintWriter与ServletOutputStream的区别之文件下载
copy自:https://blog.csdn.net/weixin_37703598/article/details/803870611.out = response.getWriter(); re ...
- springmvc视图解析
SpringMVC 视图解析的几种方式: 在视图解析的过程中,需要知道逻辑view的名字,model的名字以访问model和view. 使用jsp进行解析,InternalResourceViewRe ...
- docker-ce安装官翻
参考http://www.cnblogs.com/maple42/p/5868846.htmlhttp://blog.csdn.net/lizehua123/article/details/50601 ...
- notepad++使用NppFTP连接linux,编写shell脚本无法保存上传的问题
下载安装NppFTP插件之后,重启打开notepad++连接到linux主机,之后进行编辑shell脚本,出现无法保存上传至linux主机的问题. 分析的原因:可能的原因是Windows防火墙阻止了应 ...
- pxc增量备份
###增备数据库,如果后续还需要再次增备,则可以再次指定--extra-lsndir,如果与上次备份指定相同的位置,该文件被覆盖# innobackupex --compress --incremen ...
- python 全栈之路
目录 Python 全栈之路 一. Python 1. Python基础知识部分 2. Python -函数 3. Python - 模块 4. Python - 面对对象 5. Python - 文 ...
- 添物零基础到大型全栈架构师 不花钱学计算机及编程(预备篇)— C语言编程基础
C语言介绍 C语言基本是每个编程人员必学的一面语言,很好掌握,是理解编程的关键.很多编程语言基于其编写或者基于此语言的衍生品编写. C语言是人机交互的一个基础语言之一,虽然是之一,单一般其实就是唯一 ...
- spoj 375 树链剖分模板
/* 只是一道树链刨分的入门题,作为模板用. */ #include<stdio.h> #include<string.h> #include<iostream> ...
- [K/3Cloud] 首页增加一个自定义页签及页面内容
在K3Cloud登录后的门户首页增加一个页签,如增加一个[BBS论坛] 2013-7-30 11:18:51 上传 下载附件 (84.81 KB) 增加页签 可以这么来做: 进入BOS IDE ,找 ...
- 统计单词个数(codevs 1040)
题目描述 Description 给出一个长度不超过200的由小写英文字母组成的字母串(约定;该字串以每行20个字母的方式输入,且保证每行一定为20个).要求将此字母串分成k份(1<k<= ...