小编bra*_*ley的帖子

指定的填充模式对此算法无效 - c# - System.Security.Cryptography

对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)

c# security encryption cryptography system

9
推荐指数
1
解决办法
7169
查看次数

Angular APP_INITIALIZER 是否在延迟加载的模块内工作

我有一个延迟加载的模块,我正在尝试添加 APP_INITIALIZER 但它没有触发。我的语法与我的主应用程序完全相同,它按预期工作。延迟加载的模块是否会触发 APP_INITIALIZER?

lazy-loading initialization angular

5
推荐指数
2
解决办法
3696
查看次数