[转](.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仿真过程中会出现错误,提示非法引 ...
随机推荐
- VSCODE 针对调试C语言时一闪而过解决办法
针对调试C语言时一闪而过解决办法 前提: 已经按照 C/C++ 已经安装 MINGW(并配置完成) 原因: 主要是因为tasks的配置没有写对 解决办法: tasks.json { // See h ...
- 宽带、ADSL、以太网、PPPoE
作者:北极链接:https://www.zhihu.com/question/25847423/answer/31563282来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出 ...
- 洛谷 P2677 超级书架 2 题解
传送门 题目描述 Farmer John最近为奶牛们的图书馆添置了一个巨大的书架,尽管它是如此的大,但它还是几乎瞬间就被各种各样的书塞满了.现在,只有书架的顶上还留有一点空间. 所有N(1 <= ...
- 【洛谷2113】看球泡妹子 DP背包
看球泡妹子 题目背景 2014年巴西世界杯开幕了,现在满城皆是世界杯,商家们利用它大赚一笔,小明和小红也借此机会增进感情. 题目描述 本届世界杯共有\(N\)支球队,\(M\)场比赛.男球迷小明喜欢看 ...
- SDUT OJ 数据结构实验之二叉树二:遍历二叉树
数据结构实验之二叉树二:遍历二叉树 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descr ...
- JS 命名规范
JS的命名规则和规范 规则 - 必须遵守的,不遵守会报错 由字母.数字.下划线.$符号组成,不能以数字开头 不能是关键字和保留字,例如:for.while. 区分大小写 规范 - 建议遵守的,不遵守不 ...
- SLAM到底是什么?一文带你读懂SLAM
SLAM是Simultaneous localization and mapping缩写,意为“同步定位与建图”,主要用于解决机器人在未知环境运动时的定位与地图构建问题,为了让大家更多的了解SLAM, ...
- 20165224 陆艺杰 Exp5 MSF基础应用
用自己的话解释什么是exploit,payload,encode Exploit是攻击的行为 Payload是一段植入目标机的简短的带功能的恶意代码 Encode是编码,用于更改恶意代码,编码特征码检 ...
- D3.js v4版本 按住shift键框选节点demo
http://download.csdn.net/download/qq_25042329/10139649
- JPEG 编码
WIN8. DNJXJ-7XBW8-2378T-X22TX-BKG7J 模板:类的宏,泛型,甜饼切割机 类模板:泛型类: 函数模板:泛型函数 STL standard template Library ...