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 a using statement.
  • 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取代方法的更多相关文章

  1. [.net core学习] .net core中的MD5CryptoServiceProvider取代方法

    使用:MD5 m5 = MD5.Create(); 参考:http://stackoverflow.com/questions/27216121/alternatives-of-md5cryptose ...

  2. .Net Core 学习新建Core MVC 项目

    一.新建空的Core web项目 二.在Startup文件中添加如下配置 1.  在ConfigureServices 方法中添加 services.AddMvc();MVC服务 2. app.Use ...

  3. 1.跟着微软 https://docs.microsoft.com/zh-cn/dotnet/core/ 学习.net core

    10分钟快速使用 安装之后 打开cmd 第一步. dotnet new console -o firstApp 第二步. cd firstApp 第三部.dotnet run 这样就运行了hello ...

  4. cips2016+学习笔记︱NLP中的消岐方法总结(词典、有监督、半监督)

    歧义问题方面,笔者一直比较关注利用词向量解决歧义问题: 也许你寄希望于一个词向量能捕获所有的语义信息(例如run即是动车也是名词),但是什么样的词向量都不能很好地进行凸显. 这篇论文有一些利用词向量的 ...

  5. 学习Linux系统中命令的简单方法

    如果说如何快速学习.了解Linux的话,我的答案是学命令.背命令!为何呢?对于一名新手来说,去学习Linux的思想.了解Linux的架构.明白Linux中“一切皆文件”概念虽然说是没有错,是对的.但是 ...

  6. ASP.NET Core 学习笔记 第四篇 ASP.NET Core 中的配置

    前言 说道配置文件,基本大多数软件为了扩展性.灵活性都会涉及到配置文件,比如之前常见的app.config和web.config.然后再说.NET Core,很多都发生了变化.总体的来说技术在进步,新 ...

  7. Net core学习系列(三)——Net Core中的依赖注入

    本文通过一个维修工与工具库的例子形象的描述一下为什么要用依赖注入.它的工作原理是什么样的, 然后根据这个类比一下ASP.NET Core 中的依赖注入, 从而深刻了解它的使用方法.注意事项以及回收机制 ...

  8. ASP.NET Core学习零散记录

    赶着潮流听着歌,学着.net玩着Core 竹子学Core,目前主要看老A(http://www.cnblogs.com/artech/)和tom大叔的博客(http://www.cnblogs.com ...

  9. EF Core学习Code First

    下面通过实例来学习EF Core Code First,也就是通过EF Core迁移来完成从模型生成数据库. 本实例使用EntityFrameworkCore SQLite 数据库进行介绍,大家也可以 ...

随机推荐

  1. python3 发送邮件

    import smtplibfrom email.mime.text import MIMETextdef SendEmail(fromAdd,toAdd,subject,text): _pwd = ...

  2. 浏览器局部打印实现,iframe打印

    const handleOk = () =>{ let ele = document.getElementById('printInfor'); let iframe=window.frames ...

  3. SpringBoot中常用注解@Controller/@RestController/@RequestMapping的区别

    @Controller 处理http请求 @Controller //@ResponseBody public class HelloController { @RequestMapping(valu ...

  4. saltstack的封装和内网使用

    0.客户端使用 linux:把linux的ragent文件夹拷贝到内网linux /opt目录下,运行初始化脚本 salt服务端:# @Master:"/opt/ragent/python/ ...

  5. JSONObject.fromObject--JSON与对象的转换

    1. List集合转换成json代码 List list = new ArrayList(); list.add( "first" ); list.add( "secon ...

  6. c#随机生成英文名

    private static string GenerateSurname() {     string name = string.Empty;     string[] currentConson ...

  7. jmeter 连接 MySql

    1.连接 mysql 驱动包安装下载 1)首先需要安装 mysql 驱动包,下载地址:https://dev.mysql.com/downloads/connector/j/5.1.html 2)下载 ...

  8. java.lang.NoClassDefFoundError: org/bouncycastle/jce/provider/BouncyCastleProvider

    今天部署完一个测试war包,打开页面的时候报错: HTTP Status 500 - Handler processing failed; nested exception is java.lang. ...

  9. git clone Failed to connect to 127.0.0.1 port 43213: Connection refused

    不知道为什么使用git clone 的时候报了上面的错误,后面发现是 127.0.0.1 port 43213的端口被代理占用了,可以这样查看: $ env|grep -i proxy 结果是: NO ...

  10. MySQL 详细学习笔记

    Windows服务 -- 启动MySQL net start mysql -- 创建Windows服务 sc create mysql binPath= mysqld_bin_path(注意:等号与值 ...