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

最新文章

  1. Elasticsearch 全教程
  2. Intellisense in Visual Studio for Microsoft Dynamics CRM 2016
  3. [React] React Fundamentals: First Component
  4. Java 抽象类与接口总结
  5. GCD 单例
  6. DataTable 导出Excel 下载 (NPOI)
  7. 03-IOSCore - XML及解析、Plist
  8. Android Studio新手
  9. span设置宽度有效无效问题
  10. java开源项目之IQQ学习记录之单例模式与log4j日志记录
  11. MySQL-每日定点运行
  12. 多阶段构建Docker镜像
  13. 【转载】FPGA 中的latch 锁存器
  14. Docker学习笔记之Docker的Build 原理
  15. selenuim和phantonJs处理网页动态加载数据的爬取
  16. 第八篇:Jmeter的分布式测试
  17. gentoo系统安装
  18. [LeetCode] Contains Duplicate & Contains Duplicate II
  19. 音视频学习系列第(七)篇---MediaCodec的使用
  20. Spiral Matrix I & II

热门文章

  1. leetcode621
  2. hitTest,UIWindow sendEvent ,touchbegan, 响应链
  3. html常用代码合集
  4. Echarts 柱状图属性详解
  5. 微信小程序---setData
  6. linux下redis4.0.2集群部署(利用Ruby脚本命令)
  7. python的执行过程
  8. H5学习的例子
  9. hdoj2089(入门数位dp)
  10. 213. House Robber II 首尾相同的偷窃问题