Net6下加密类过期更新
1. warning SYSLIB0021: “DESCryptoServiceProvider”已过时:“Derived cryptographic types are obsolete. Use the Create method on the base type instead.”
var des = new DESCryptoServiceProvider(); 修改为:using var des = DES.Create();
2. warning SYSLIB0021: MD5CryptoServiceProvider”已过时:“Derived cryptographic types are obsolete. Use the Create method on the base type instead.
MD5 md5 = new MD5CryptoServiceProvider(); 修改为: using MD5 md5 = MD5.Create();
3. warning SYSLIB0021: “SHA1Managed”已过时:“Derived cryptographic types are obsolete. Use the Create method on the base type instead.”
var hash = new SHA1Managed(); 替换为: using var hash = SHA1.Create(); 其他类似: SHA256.Create(); SHA512.Create();
4. “RNGCryptoServiceProvider”已过时:“RNGCryptoServiceProvider is obsolete. To generate a random number, use one of the RandomNumberGenerator static methods instead.”
RandomNumberGenerator.GetInt32(Int32) RandomNumberGenerator.Create()
5. warning SYSLIB0022: “RijndaelManaged”已过时:“The Rijndael and RijndaelManaged types are obsolete. Use Aes instead.”
var rDel = new RijndaelManaged(); 替换为 using var rDel = Aes.Create("AesManaged")
记得都加上using及时释放资源!!
using