[转](.NET Core C#) AES Encryption
本文转自:https://www.example-code.com/dotnet-core/crypt2_aes.asp
Chilkat.Crypt2 crypt = new Chilkat.Crypt2(); bool success = crypt.UnlockComponent("Anything for 30-day trial");
if (success != true) {
Console.WriteLine(crypt.LastErrorText);
return;
} // AES is also known as Rijndael.
crypt.CryptAlgorithm = "aes"; // CipherMode may be "ecb", "cbc", "ofb", "cfb", "gcm", etc.
// Note: Check the online reference documentation to see the Chilkat versions
// when certain cipher modes were introduced.
crypt.CipherMode = "cbc"; // KeyLength may be 128, 192, 256
crypt.KeyLength = ; // The padding scheme determines the contents of the bytes
// that are added to pad the result to a multiple of the
// encryption algorithm's block size. AES has a block
// size of 16 bytes, so encrypted output is always
// a multiple of 16.
crypt.PaddingScheme = ; // EncodingMode specifies the encoding of the output for
// encryption, and the input for decryption.
// It may be "hex", "url", "base64", or "quoted-printable".
crypt.EncodingMode = "hex"; // An initialization vector is required if using CBC mode.
// ECB mode does not use an IV.
// The length of the IV is equal to the algorithm's block size.
// It is NOT equal to the length of the key.
string ivHex = "000102030405060708090A0B0C0D0E0F";
crypt.SetEncodedIV(ivHex,"hex"); // The secret key must equal the size of the key. For
// 256-bit encryption, the binary secret key is 32 bytes.
// For 128-bit encryption, the binary secret key is 16 bytes.
string keyHex = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F";
crypt.SetEncodedKey(keyHex,"hex"); // Encrypt a string...
// The input string is 44 ANSI characters (i.e. 44 bytes), so
// the output should be 48 bytes (a multiple of 16).
// Because the output is a hex string, it should
// be 96 characters long (2 chars per byte).
string encStr = crypt.EncryptStringENC("The quick brown fox jumps over the lazy dog.");
Console.WriteLine(encStr); // Now decrypt:
string decStr = crypt.DecryptStringENC(encStr);
Console.WriteLine(decStr);
[转](.NET Core C#) AES Encryption的更多相关文章
- AES encryption of files (and strings) in java with randomization of IV (initialization vector)
http://siberean.livejournal.com/14788.html Java encryption-decryption examples, I've seen so far in ...
- [JavaSecurity] - AES Encryption
1. AES Algorithm The Advanced Encryption Standard (AES), also as known as Rijndael (its original nam ...
- AES加密 C++调用Crypto++加密库 样例
这阵子写了一些数据加密的小程序,对照了好几种算法后,选择了AES,高级加密标准(英语:Advanced Encryption Standard,缩写:AES).听这名字就非常厉害的样子 预计会搜索到这 ...
- PHP的AES加密类
PHP的AES加密类 aes.php <?php /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ...
- C++的AES加解密
最近公司项目要做个WPF程序,但是底层加密部分要用C++来实现.通过网上搜索各种资料,地址已经记不下了,没发贴出来了! 下面看看如何加解密的~!先贴代码.... string tKey(sKey); ...
- Crypto++入门学习笔记(DES、AES、RSA、SHA-256)
最先附上 下载地址 背景(只是个人感想,技术上不对后面的内容构成知识性障碍,可以skip): 最近,基于某些原因和需要,笔者需要去了解一下Crypto++库,然后对一些数据进行一些加密解密的操作. 笔 ...
- Windows10 VS2017 C++使用crypto++库加密解密(AES)
参考文章: https://blog.csdn.net/tangcaijun/article/details/42110319 首先下载库: https://www.cryptopp.com/#dow ...
- AES Test vectors
Table of content List of test vectors for AES/ECB encryption mode AES ECB 128-bit encryption mode AE ...
- aes加密/解密(转载)
这篇文章是转载的康奈尔大学ece5760课程里边的一个final project,讲的比较通俗易懂,所以转载过来.附件里边是工程文件,需要注意一点,在用modelsim仿真过程中会出现错误,提示非法引 ...
随机推荐
- react中使用echarts(人物关系图)
项目中有时会用到echarts,可能不同的框架中语法稍有变通,前几天在react项目中遇到,写此篇以作记录. 不同的charts语法跟支持不同,本篇"echarts": " ...
- 6w6:第六周程序填空题3
描述 下面的程序输出结果是: A::Fun A::Do A::Fun C::Do 请填空: #include <iostream> using namespace std; class A ...
- F - ACboy needs your help again! (模拟)
ACboy was kidnapped!! he miss his mother very much and is very scare now.You can't image how dark th ...
- Kubernetes 集群部署(4) -- Node 部署
以下无特殊说明,都是在 Node 节点运行 1. 创建文件 vim /opt/k8s/cfg/kubelet.conf,内容如下: KUBELET_OPTS="--logtostderr=t ...
- 在虚拟机中连接oracle数据库报错ORA-12154,其他服务器连接无问题
在一台服务器上使用sqlplus登录oracle数据库,cmd->sqlplus->name/passwd@orcl2登录某个数据库用户,提示ORA-12154.使用当前服务器的PLSQL ...
- CF1137F Matches Are Not a Child's Play(树链剖分)
题面 我们定义一棵树的删除序列为:每一次将树中编号最小的叶子删掉,将该节点编号加入到当前序列的最末端,最后只剩下一个节点时将该节点的编号加入到结尾. 例如对于上图中的树,它的删除序列为:2 4 3 1 ...
- 解决因为链表过长,sql查询慢的问题
/** * 解决因为链表过长,sql查询慢的问题 * 使用分治算法,先切分链表,然后查询结果,最后合并结果 * * @author lingpy * @since 1.0 */public clas ...
- casperjs进行web功能自动化测试demo
通过一周多的学习和总结,终于掌握了casperjs用于自动化的方法,填平了大大小小的各种坑. casperjs是一个新兴的测试框架,网上资料很少,基本上靠翻译英文资料. 贡献出来,供大家参考: / ...
- P3230 [HNOI2013]比赛
$ \color{#0066ff}{ 题目描述 }$ 沫沫非常喜欢看足球赛,但因为沉迷于射箭游戏,错过了最近的一次足球联赛.此次联 赛共N支球队参加,比赛规则如下: (1) 每两支球队之间踢一场比赛. ...
- 《Andrew Ng深度学习》笔记3
浅层神经网络 初步了解了神经网络是如何构成的,输入+隐藏层+输出层.一般从输入层计算为层0,在真正计算神经网络的层数时不算输入层.隐藏层实际就是一些算法封装成的黑盒子.在对神经网络训练的时候,就是对神 ...