[.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 数据库进行介绍,大家也可以 ...
随机推荐
- 星级评分原理 N次重写的分析
使用的是雪碧图,用的软件是CSS Sprite Tools 第一次实现与分析: <!DOCTYPE html> <html> <head> <meta cha ...
- leetcode312
class Solution { public int maxCoins(int[] iNums) { int[] nums = new int[iNums.length + 2]; int n = ...
- js 生成手机图片并保存到相册
1.注意权限问题 2.调用HTML5+api 3.优化显示 4.注意兼容ios.Android
- EF 6.x实现dynamic动态查询
利用SqlQuery实现动态查询 public static IEnumerable<dynamic> SqlQueryDynamic(this DbContext db, string ...
- Caffe:如何将图片数据转换成lmdb文件
1 图片信息的转换 在caffe中经常使用的数据类型是lmdb或leveldb;不是常见的jpg,jpeg,png,tif等格式;因此,需要进行格式转换,通过输入你自己的图片目录(下有的大量图片)转换 ...
- # 20175213 2018-2019-2 《Java程序设计》第1周学习总结
在本周的java学习中,我收获了很多也遇到了很多的困难1.在寒假的预学习中,因为没能完全的安好虚拟机,导致在本周的学习一开始,虚拟机就崩溃了,所以又重新开始重头安装虚拟机.但因为网速等各种问题,虚拟机 ...
- java虚拟机--->>程序计数器
程序计数器是一块较小的内存空间,他可以看做是当前线程所执行的行号指示器.在虚拟机的概念模型(仅是概念模型,各种虚拟机可能会通过一些更高效率的方式去实现)里,字节码解释器工作室就是通过改变这个计数器的值 ...
- 突然发现用PHP做多条件模糊查询很简单
原文:http://blog.csdn.net/suleil1/article/details/49471099 所使用的方法:$sqlArr=array();array_push();implode ...
- eclipse中启动项目报内存溢出问题通过修改配置解决
标注:添加下面的参数还是挺管用的,本人亲测可试,同时启用两个项目,总是报堆内存不足,加了下面的参数后变可以同时正常运行了. 错误如下: Error occurred during initializ ...
- Python开发——数据类型【字典】
字典的定义 # Python语言中唯一的类型映射 # 键与值之间用“:”分开 # 项与项之间用“,”分开 person = {"name":"yuan",&qu ...