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. http 文件上传协议图览

  2. python excel 像 Excel 一样使用 python 进行数据分析

    https://www.jb51.net/article/63216.htm 像 Excel 一样使用 python 进行数据分析 :  https://www.cnblogs.com/nxld/p/ ...

  3. 源码阅读经验谈-slim,darknet,labelimg,caffe(1)

    本文首先谈自己的源码阅读体验,然后给几个案例解读,选的例子都是比较简单.重在说明我琢磨的点线面源码阅读方法.我不是专业架构师,是从一个深度学习算法工程师的角度来谈的,不专业的地方请大家轻拍. 经常看别 ...

  4. LAMP架构

    LAMP(linux,apache,mysql,php)是linux系统下常用的网站架构模型,用来运行PHP网站.(这得apache是httpd服务),这些服务可以安装同意主机上,也可以安装不同主机上 ...

  5. CDialogEx::OnPaint()的问题,或者为什么在对话框程序的OnPaint中绘图无效的问题

    这是一个基于对话框的程序,对话框上有按钮,还有几个CStatic用来绘图,之前都是好好的,今天改成Unicode版本后,编译正常,运行时CStatic中的图像怎么也不显示,有时候会闪现一次就消失,问题 ...

  6. cadence 17.2 安装破解

    安装包都在gaobo百度云/工具/开发工具  或者    下载链接 进去pcb edit 可能会提示 licese什么的,忽略就可以了.

  7. DJango 基础(6)

    Django模型基础 知识点: 数据库的配置 使用django中的模型 将模型映射到数据库 数据的增删改查基本操作 数据库的配置 1.在settings.py中配置DATABASES: DATABAS ...

  8. python argparse(参数解析)模块学习(二)

    转载自:http://www.cnblogs.com/fireflow/p/4841389.html(我去..没转载功能,ctrl + c 和 ctrl + v 得来的,格式有点问题,可去原版看看) ...

  9. NTFS(Windows)、ext4(RHEL6)和xfs(RHEL7)文件系统的误删除恢复和备份

    前言 对于误删除文件的设备,要马上停止任何写的操作,防止删除的文件被覆盖,导致数据丢失! 恢复NTFS文件系统下误删的文件 以Windows为例,市面上能恢复的工具不少,例如EasyRecovery. ...

  10. HDU 3594.Cactus 仙人掌图

    Cactus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...