[转](.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仿真过程中会出现错误,提示非法引 ...
随机推荐
- fwrite()
注:fwrite(),fread -可对数据块读写,且数据为二进制,文本下查看为乱码,文件的打开方式为 “b*” 实例: 写入二进制数据 for (int i = 0; i < SN; i++) ...
- 用Hadoop,还是不用Hadoop?
本文由 伯乐在线 - Lex Lian 翻译.英文出处:Anand Krishnaswamy.欢迎加入翻译小组. Hadoop通常被认定是能够帮助你解决所有问题的唯一方案. 当人们提到“大数据”或是“ ...
- EOS 智能合约 plublic key 转换
在做一个EOS 的action接口时,定义如下: void setbplist(const account_name bp_name, const uint64_t bp_time, const ...
- opencv学习笔记2
import cv2 as cvimport numpy as np"""#图像加法运算 即像素加法 (结果图=图1+图二) (两个图像必须是等大等类型的)image = ...
- 一款给力的一键复制js插件-clipboard.js
一款没有依赖的.给力的一键复制的JS插件 点我前往github 案例demo见下载包内demo文件夹. 这里晒出最常用的几种方式,以供不时之需. <!DOCTYPE html> < ...
- 洛谷 P3376【模板】网络最大流
题目描述 如题,给出一个网络图,以及其源点和汇点,求出其网络最大流. 输入输出格式 输入格式: 第一行包含四个正整数N.M.S.T,分别表示点的个数.有向边的个数.源点序号.汇点序号. 接下来M行每行 ...
- springboot整合mybatis,redis,代码(二)
一 说明: springboot整合mybatis,redis,代码(一) 这个开发代码的复制粘贴,可以让一些初学者直接拿过去使用,且没有什么bug 二 对上篇的说明 可以查看上图中文件: 整个工程包 ...
- python 安装 wxPtyhon (window)
检查是否安装pip 打开cmd(全局安装的python)测试是否安装了pip 工具 以上是安装了pip , 执行下载并安装 wxPtyhon 第一种方法: 也可以使用其他的地址 官网地址 https: ...
- MITK 手册
可怜这么有用的开源竟然没有中文手册, MITK Plugin Manuals Overview The Basic Image Processing Plugin The DataManager ...
- hdu1022 模拟栈
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...