[/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. vs code 格式化vue代码

    1.安装 vetur 2.文件-首选项-设置 增加 "vetur.format.defaultFormatter.html": "js-beautify-html&quo ...

  2. Docker Swarm集群中部署Traefik负载均衡器

    一.创建单节点的Docker Swarm集群 docker swarm init 二.在Swarm集群中创建一个网络 docker network create --driver=overlay tr ...

  3. PowerDesigner概念(概念数据模型概述)

  4. 初学spring笔记

    简单hello world 项目,了解IOC 反转控制

  5. Adb工具的简单使用

    Adb全称为Android Debug Bridge adb就是连接android手机与PC机的桥梁,可以在pc端对手机进行全面的操作 借助adb工具,可以管理设备或者手机模拟器的状态,进行手机操作, ...

  6. C# 结构与类的区别

    一.定义方式 定义结构: struct PointStruct //默认的访问权限是 public { public int X { get; set; } public int Y { get; s ...

  7. Vue 给axios做个靠谱的封装(报错,鉴权,跳转,拦截,提示)

    需求及实现 统一捕获接口报错 弹窗提示 报错重定向 基础鉴权 表单序列化 用法及封装 用法 // 服务层 , import默认会找该目录下index.js的文件,这个可能有小伙伴不知道可以去了解npm ...

  8. idea springboot jrebel hotreloaded

    http://127.0.0.1:8888/88414687-3b91-4286-89ba-2dc813b107ce

  9. MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.7 Adding a wms layer

    MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.7 Adding a wms layer 前言 Add OGC WMS Layers( ...

  10. lr12关联,响应乱码

    1.前程贷登录.投标脚本 Action() { //    web_url("登录页", //        "URL=http://120.78.128.25:8765 ...