[.net core学习] .net core中的Rijndael取代方法
The difference (in .NET) between Rijndael and AES is that Rijndael allows the block size to change, but AES does not. Since RijndaelManaged's default block size is the same as the AES block size (128 bit / 16 byte) you are, in fact, using AES.
Instead of instantiating the implementation type by name, just use the factory (Aes.Create()). That works in both .NET Core and .NET Framework.
Other things worth mentioning:
- All SymmetricAlgorithm instances are IDisposable, you should use them in a
usingstatement. - All ICryptoTransform instances (such as your incorrectly named
desEncryptor) are IDisposable, you should use them in ausingstatement. - ISO10126 padding is not available in .NET Core 1.0. If you need to be compatible with existing streams you can apply the padding yourself and specify PaddingMode.None. Otherwise, PKCS7 is more standard.
- Your AES key isn't very random, since it comes from an ASCII string (lots of values won't be valid).
- Base64 at least has full value range
- PBKDF2 (Password-Based Key Derivation Function 2) via the Rfc2898DeriveBytes class allows for shared-string-secret in, predictable noise out.
- KeyAgreement is in general better, but neither ECDH nor classic DH are available in .NET Core 1.0.
- Usually the encryptor should let a random IV be calculated (call
aes.GenerateIV()if using the same object for multiple operations) and present it with the ciphertext. So encrypt takes a key and plaintext and produces a ciphertext and IV. Decrypt takes (key, IV, ciphertext) and produces plaintext.
用法: SymmetricAlgorithm des = Aes.Create();
参考:http://stackoverflow.com/questions/38333722/how-to-use-rijndael-encryption-with-a-net-core-class-library-not-net-framewo
[.net core学习] .net core中的Rijndael取代方法的更多相关文章
- [.net core学习] .net core中的MD5CryptoServiceProvider取代方法
使用:MD5 m5 = MD5.Create(); 参考:http://stackoverflow.com/questions/27216121/alternatives-of-md5cryptose ...
- .Net Core 学习新建Core MVC 项目
一.新建空的Core web项目 二.在Startup文件中添加如下配置 1. 在ConfigureServices 方法中添加 services.AddMvc();MVC服务 2. app.Use ...
- 1.跟着微软 https://docs.microsoft.com/zh-cn/dotnet/core/ 学习.net core
10分钟快速使用 安装之后 打开cmd 第一步. dotnet new console -o firstApp 第二步. cd firstApp 第三部.dotnet run 这样就运行了hello ...
- cips2016+学习笔记︱NLP中的消岐方法总结(词典、有监督、半监督)
歧义问题方面,笔者一直比较关注利用词向量解决歧义问题: 也许你寄希望于一个词向量能捕获所有的语义信息(例如run即是动车也是名词),但是什么样的词向量都不能很好地进行凸显. 这篇论文有一些利用词向量的 ...
- 学习Linux系统中命令的简单方法
如果说如何快速学习.了解Linux的话,我的答案是学命令.背命令!为何呢?对于一名新手来说,去学习Linux的思想.了解Linux的架构.明白Linux中“一切皆文件”概念虽然说是没有错,是对的.但是 ...
- ASP.NET Core 学习笔记 第四篇 ASP.NET Core 中的配置
前言 说道配置文件,基本大多数软件为了扩展性.灵活性都会涉及到配置文件,比如之前常见的app.config和web.config.然后再说.NET Core,很多都发生了变化.总体的来说技术在进步,新 ...
- Net core学习系列(三)——Net Core中的依赖注入
本文通过一个维修工与工具库的例子形象的描述一下为什么要用依赖注入.它的工作原理是什么样的, 然后根据这个类比一下ASP.NET Core 中的依赖注入, 从而深刻了解它的使用方法.注意事项以及回收机制 ...
- ASP.NET Core学习零散记录
赶着潮流听着歌,学着.net玩着Core 竹子学Core,目前主要看老A(http://www.cnblogs.com/artech/)和tom大叔的博客(http://www.cnblogs.com ...
- EF Core学习Code First
下面通过实例来学习EF Core Code First,也就是通过EF Core迁移来完成从模型生成数据库. 本实例使用EntityFrameworkCore SQLite 数据库进行介绍,大家也可以 ...
随机推荐
- 非virtual函数,用指针进行upcast
void print_func(A* p) { p -> print(); } int main() { A a(); B b(,); //a.print(); //b.print(); pri ...
- azkaban 配置邮件
1.配置邮件请在azkaban-web-server中进行配置:如下图: /opt/azkaban/azkaban/azkaban-web-server/build/install/azka ...
- HLSL ddx / ddy
[HLSL ddx / ddy] 在光栅化的时刻,GPUs会在同一时刻并行运行很多Fragment Shader,但是并不是一个pixel一个pixel去执行的,而是将其组织在2x2的一组pixels ...
- redis5 集群迁移方案
Redis5 集群迁移方案 一.KEY优化 1.按原来要求进行优化与大KEY分拆. 二.现Redis 集群缩容(对业务无影响) 主节点按要求合并至3个主节点. 业务配置为3主4从 删除没有槽的主节点与 ...
- pipeline-安全测试
代码安全检查 需要安装SonarQube(版本6.7,安装了Findbugs插件) MySQL >=5.6,笔者安装的是MySQL 5.7版本 Jenkins需要安装下列插件: SonarQub ...
- Python+Selenium学习--下载文件
场景 webdriver 允许我们设置默认的文件下载路径.也就是说文件会自动下载并且存在设置的那个目录中,下面以firefox及chrome为例 代码 Firefox下载 为了让Firefox浏览器能 ...
- f5 主备模式切换
f5 主备模式 主机down自动切换到备 原主机重新启动,自动切换到原主机
- Linux下查看磁盘挂载的几种方法
Linux下查看磁盘挂载的几种方法 第一种方法:df命令 # df -hT Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtm ...
- 46-2016 蓝桥杯 java B 组
1.煤球数目 有一堆煤球,堆成三角棱锥形.具体: 第一层放1个, 第二层3个(排列成三角形), 第三层6个(排列成三角形), 第四层10个(排列成三角形), .... 如果一共有100层,共有多少个煤 ...
- JSP的简单介绍
什么是JSP? JSP全称是Java Server Pages,它和servle技术一样,都是SUN公司定义的一种用于开发动态web资源的技术. JSP这门技术的最大的特点在于,写jsp就像在写htm ...