[/font]using System.Collections;
using System.Text;
using System.Security.Cryptography;
using System;
[font=黑体]//
//                  _ooOoo_
//                 o8888888o
//                 88" . "88
//                 (| -_- |)
//                 O\  =  /O
//              ____/`---'\____
//            .'  \\|     |//  `.
//          /  \\|||  :  |||//  \
//          /  _||||| -:- |||||-  \
//          |   | \\\  -  /// |   |
//          | \_|  ''\---/''  |   |
//          \  .-\__  `-`  ___/-. /
//        ___`. .'  /--.--\  `. . __
//     ."" '<  `.___\_<|>_/___.'  >'"".
//    | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//    \  \ `-.   \_ __\ /__ _/   .-` /  /
//=====`-.____`-.___\_____/___.-`____.-'======
//                  `=---='
//
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//          佛祖保佑       永无Bug
//          快加工资       不改需求
//
public class ADDJIEMI : MonoBehaviour [/font][font=黑体]{
public UIInput _input;
//获取输入框的值
private string inputText;
//被加密内容
private string strEncryption;
private string strkeyValue;
void Start()
{
//加密和解密采用相同的key,可以任意数字,但是必须为32位
strkeyValue = "12345678901234567890198915689039";
}
public void encryptionClick()
{
inputText = _input.value;
strEncryption=encryptionContent(inputText, strkeyValue);
Debug.Log(strEncryption);
}
public void decipherClick()
{
inputText = decipheringContent(strEncryption, strkeyValue);
Debug.Log(inputText);
}
/// <summary>
/// 内容加密
/// </summary>
/// <param name="ContentInfo">要加密内容</param>
/// <param name="strkey">key值</param>
/// <returns></returns>
public string encryptionContent(string ContentInfo,string strkey)
{
byte[] keyArray = UTF8Encoding.UTF8.GetBytes(strkey);
RijndaelManaged encryption = new RijndaelManaged();
encryption.Key = keyArray;
encryption.Mode = CipherMode.ECB;
encryption.Padding = PaddingMode.PKCS7;
ICryptoTransform cTransform = encryption.CreateEncryptor();
byte[] _EncryptArray = UTF8Encoding.UTF8.GetBytes(ContentInfo);
byte[] resultArray = cTransform.TransformFinalBlock(_EncryptArray, 0, _EncryptArray.Length);
return Convert.ToBase64String(resultArray, 0, resultArray.Length);
}
 
/// <summary>
/// 内容解密
/// </summary>
/// <param name="encryptionContent">被加密内容</param>
/// <param name="strkey">key值</param>
/// <returns></returns>
public string decipheringContent(string encryptionContent,string strkey)
{
byte[] keyArray = UTF8Encoding.UTF8.GetBytes(strkey);
RijndaelManaged decipher = new RijndaelManaged();
decipher.Key = keyArray;
decipher.Mode = CipherMode.ECB;
decipher.Padding = PaddingMode.PKCS7;
ICryptoTransform cTransform = decipher.CreateDecryptor();
byte[] _EncryptArray = Convert.FromBase64String(encryptionContent);
byte[] resultArray = cTransform.TransformFinalBlock(_EncryptArray, 0, _EncryptArray.Length);
return UTF8Encoding.UTF8.GetString(resultArray);
}
}

unity3d 数据加/解密的更多相关文章

  1. T-SQL问题解决集锦——数据加解密(2)

    原文:T-SQL问题解决集锦--数据加解密(2) 问题三.如何让指定用户可以对数据表进行Truncate操作? Truncate在对大表全删除操作时,会明显比Delete语句更快更有效,但是因为它不需 ...

  2. T-SQL问题解决集锦——数据加解密

    原文:T-SQL问题解决集锦--数据加解密 以下代码已经在SQLServer2008上的示例数据库测试通过 问题一:如何为数据进行加密与解密,避免使用者窃取机密数据? 对于一些敏感数据,如密码.卡号, ...

  3. shiro框架学习-6-Shiro内置的Filter过滤器及数据加解密

    1.  shiro的核心过滤器定义在枚举类DefaultFilter 中,一共有11个 ,配置哪个路径对应哪个拦截器进行处理 // // Source code recreated from a .c ...

  4. ASP.NET Core 6框架揭秘实例演示[19]:数据加解密与哈希

    数据保护(Data Protection)框架旨在解决数据在传输与持久化存储过程中的一致性(Integrity)和机密性(confidentiality)问题,前者用于检验接收到的数据是否经过篡改,后 ...

  5. 个人永久性免费-Excel催化剂功能第62波-单元格区域内数据加解密处理,最有效地保护数据方式

    Excel的数据保护能力有限,诸如之前提及过的工作表保护.工作薄保护等,都是十分微弱的保护措施,而对于强保护的工作薄打开密码来说,它像是个总开关一样,要么全不能看,要么就全看到.有这样的场景需求,一份 ...

  6. java基础/数据加解密(Mooc)

    一.消息摘要算法 常用摘要算法: 以下 (HEX)内容:bc指Bouncy Castle  |  cc指:Apache commons Codec 1.消息摘要算法MD5及MD族(MD2,MD4) 消 ...

  7. php利用自定义key,对数据加解密的方法

    客户端和服务端通信时,有个场景很常见,通过一个id作为url参数来回传递.假设现在业务上只有这个id标识,那么需要稍微安全一点的通信,对这个id进行加密传输,到服务端再进行解密.这里需要一个服务端进行 ...

  8. Java中使用OpenSSL生成的RSA公私钥进行数据加解密

    当前使用的是Linux系统,已经按装使用OpenSSL软件包, 一.使用OpenSSL来生成私钥和公钥 1.执行命令openssl version -a 验证机器上已经安装openssl 1 open ...

  9. Java中使用OpenSSL生成公钥私钥进行数据加解密

    当前使用的是Linux系统,已经安装OpenSSL软件包. 一.使用OpenSSL来生成私钥和公钥1.执行命令openssl version -a 验证机器上已经安装openssl $ openssl ...

随机推荐

  1. react项目中页面跳转、刷新及获取网络状态

    // 页面跳转 window.location.href = 'http://speedtest.wangxiaotong.com/' // 页面刷新 window.location.reload() ...

  2. 实验八 <FBG> 基于原型的团队项目需求调研与分析

    <FBG>团队项目原型设计:http://www.cnblogs.com/ymm3/p/9012534.html GitHub的链接地址:https://github.com/FBGfbg ...

  3. JAVA-重载(overload)和重写(overrite)

    1.重载发生在同一个类中.有多个方法名相同,但是参数列表不同(包括参数个数和参数类型),和返回值无关,权限修饰符也无关. 2.重写(即覆盖)发生在子类和父类中.子类和父类的方法名.参数列表相同:子类的 ...

  4. Intel收购半导体设计公司eASIC

    来源:本文由公众号 半导体行业观察(ID:icbank)翻译自「anandtech」,谢谢. 北京时间今天凌晨,Intel宣布收购了半导体设计公司eASIC. eASIC的商业模式介于传统Fables ...

  5. 【细小碎的oi小知识点总结贴】不定时更新(显然也没人看qwq)

    1.memcpy: 从a数组中复制k个元素到b数组: memcpy(b,a,sizeof(int)*k); #include<cstring> #include<iostream&g ...

  6. Vue之添加全局变量

    定义全局变量 原理: 设置一个专用的的全局变量模块文件,模块里面定义一些变量初始状态,用export default 暴露出去,在main.js里面使用Vue.prototype挂载到vue实例上面或 ...

  7. selenium自动化定位方式

    自动化定位方式 1.String Xpath = String.format("//*[@id=\"saveFileKeyWordsBtnHand\"]/../../.. ...

  8. CodeIgniter框架解析

    转载于:https://www.cnblogs.com/xiaoxiaoqingyi/p/6901654.html 转载仅为以后自己学习. 业余花了点时间看看CodeIgniter框架(简称CI),C ...

  9. 牛客网暑期ACM多校训练营(第七场)Bit Compression

    链接:https://www.nowcoder.com/acm/contest/145/C 来源:牛客网 题目描述 A binary string s of length N = 2n is give ...

  10. Python3列表(list)比较操作教程

    一.相等比较 1.1 同顺序列表比较 顺序相同直接用“==”进行比较即可 list1 = ["one","two","three"] lis ...