对c#来说很新,目前在解密长密码时遇到问题,错误是
指定的密钥不是此算法的有效大小
我知道这与加密密码位长度不受支持有关,但不确定如何建议允许这些更长密码的方法.
这是我的加密和解密
"cipherKey":"0123456789abcdef","cipherVector":"somereallycooliv"
using System;
using System.Security.Cryptography;
using System.IO;
using System.Text;
namespace DataApi
{
public class Encryption
{
private readonly IConfigurationService _configService;
private const string _vector = "cipherVector";
private const string _key = "cipherKey";
public Encryption(IConfigurationService configService)
{
_configService = configService;
}
public string EncryptString(string text)
{
if(string.IsNullOrEmpty(text))
{
return "";
}
try
{
var key = Encoding.UTF8.GetBytes(_configService.Get(_key));
byte[] IV = Encoding.ASCII.GetBytes(_configService.Get(_vector));
using (var aesAlg = Aes.Create())
{
using (var encryptor = aesAlg.CreateEncryptor(key, IV))
{
using (var msEncrypt …Run Code Online (Sandbox Code Playgroud) 我有一个延迟加载的模块,我正在尝试添加 APP_INITIALIZER 但它没有触发。我的语法与我的主应用程序完全相同,它按预期工作。延迟加载的模块是否会触发 APP_INITIALIZER?