久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  1. <tfoot id='q2Kzy'></tfoot>
    • <bdo id='q2Kzy'></bdo><ul id='q2Kzy'></ul>

    <legend id='q2Kzy'><style id='q2Kzy'><dir id='q2Kzy'><q id='q2Kzy'></q></dir></style></legend>
  2. <i id='q2Kzy'><tr id='q2Kzy'><dt id='q2Kzy'><q id='q2Kzy'><span id='q2Kzy'><b id='q2Kzy'><form id='q2Kzy'><ins id='q2Kzy'></ins><ul id='q2Kzy'></ul><sub id='q2Kzy'></sub></form><legend id='q2Kzy'></legend><bdo id='q2Kzy'><pre id='q2Kzy'><center id='q2Kzy'></center></pre></bdo></b><th id='q2Kzy'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='q2Kzy'><tfoot id='q2Kzy'></tfoot><dl id='q2Kzy'><fieldset id='q2Kzy'></fieldset></dl></div>

    <small id='q2Kzy'></small><noframes id='q2Kzy'>

      指定的填充模式對此算法無效 - c# - System.Securit

      Specified padding mode is not valid for this algorithm - c# - System.Security.Cryptography(指定的填充模式對此算法無效 - c# - System.Security.Cryptography)
    1. <legend id='lLu6N'><style id='lLu6N'><dir id='lLu6N'><q id='lLu6N'></q></dir></style></legend>
    2. <small id='lLu6N'></small><noframes id='lLu6N'>

        <i id='lLu6N'><tr id='lLu6N'><dt id='lLu6N'><q id='lLu6N'><span id='lLu6N'><b id='lLu6N'><form id='lLu6N'><ins id='lLu6N'></ins><ul id='lLu6N'></ul><sub id='lLu6N'></sub></form><legend id='lLu6N'></legend><bdo id='lLu6N'><pre id='lLu6N'><center id='lLu6N'></center></pre></bdo></b><th id='lLu6N'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='lLu6N'><tfoot id='lLu6N'></tfoot><dl id='lLu6N'><fieldset id='lLu6N'></fieldset></dl></div>

        • <bdo id='lLu6N'></bdo><ul id='lLu6N'></ul>
              <tbody id='lLu6N'></tbody>

              <tfoot id='lLu6N'></tfoot>

                本文介紹了指定的填充模式對此算法無效 - c# - System.Security.Cryptography的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                對 c# 非常陌生,目前在解密長密碼時遇到問題,錯誤為

                pretty new to c# and currently having a problem decrypting long passwords with an error of

                指定的密鑰不是該算法的有效大小

                Specified key is not a valid size for this algorithm

                我知道這與不支持加密密碼位長度有關,但不確定如何采用建議的方法來允許這些更長的密碼.

                I know this has something to do with the encrypted password bits length not being supported but unsure how to go about suggested ways to allow for these longer passwords.

                這是我的加密和解密

                cipherKey":0123456789abcdef",cipherVector":有點酷"

                "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 = new MemoryStream())
                                {
                                    using (var csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
                                    using (var swEncrypt = new StreamWriter(csEncrypt))
                                    {
                                        swEncrypt.Write(text);
                                    }
                
                                    var decryptedContent = msEncrypt.ToArray();
                
                                    var result = new byte[IV.Length + decryptedContent.Length];
                
                                    Buffer.BlockCopy(IV, 0, result, 0, IV.Length);
                                    Buffer.BlockCopy(decryptedContent, 0, result, IV.Length, decryptedContent.Length);
                
                                    return Convert.ToBase64String(result);
                                }
                            }
                        }
                        }
                        catch(Exception e) {
                             Loggifer.Error("Unable to encrypt string: "+text , e );
                
                            throw e;
                        }
                    }
                
                    public string DecryptString(string cipherText)
                    {
                        if(string.IsNullOrEmpty(cipherText))
                        {
                            return "";
                        }
                        try
                        {
                            var fullCipher = Convert.FromBase64String(cipherText);
                
                            byte[] IV = Encoding.ASCII.GetBytes(_configService.Get(_vector));
                            var cipher = new byte[16];
                
                            Buffer.BlockCopy(fullCipher, 0, IV, 0, IV.Length);
                            Buffer.BlockCopy(fullCipher, IV.Length, cipher, 0, IV.Length);
                            var key = Encoding.UTF8.GetBytes(_configService.Get(_key));
                
                            using (var aesAlg = Aes.Create())
                            {
                                using (var decryptor = aesAlg.CreateDecryptor(key, IV))
                                {
                                    string result;
                                    using (var msDecrypt = new MemoryStream(cipher))
                                    {
                                        using (var csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
                                        {
                                            using (var srDecrypt = new StreamReader(csDecrypt))
                                            {
                                                result = srDecrypt.ReadToEnd();
                                            }
                                        }
                                    }
                
                                    return result;
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Loggifer.Error("Unable to decrypt string: "+cipherText , e );
                            throw e;
                        }
                    }
                
                }
                }
                

                推薦答案

                函數public string DecryptString(string cipherText)

                 var cipher = new byte[fullCipher.Length - IV.Length];
                

                 Buffer.BlockCopy(fullCipher, IV.Length, cipher, 0, fullCipher.Length - IV.Length);
                

                這篇關于指定的填充模式對此算法無效 - c# - System.Security.Cryptography的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                onClick event for Image in Unity(Unity中圖像的onClick事件)
                Running Total C#(運行總 C#)
                Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                Calling A Button OnClick from a function(從函數調用按鈕 OnClick)
                    <tbody id='VQSQZ'></tbody>

                  <tfoot id='VQSQZ'></tfoot>

                    <small id='VQSQZ'></small><noframes id='VQSQZ'>

                          <bdo id='VQSQZ'></bdo><ul id='VQSQZ'></ul>
                          <legend id='VQSQZ'><style id='VQSQZ'><dir id='VQSQZ'><q id='VQSQZ'></q></dir></style></legend>
                        • <i id='VQSQZ'><tr id='VQSQZ'><dt id='VQSQZ'><q id='VQSQZ'><span id='VQSQZ'><b id='VQSQZ'><form id='VQSQZ'><ins id='VQSQZ'></ins><ul id='VQSQZ'></ul><sub id='VQSQZ'></sub></form><legend id='VQSQZ'></legend><bdo id='VQSQZ'><pre id='VQSQZ'><center id='VQSQZ'></center></pre></bdo></b><th id='VQSQZ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='VQSQZ'><tfoot id='VQSQZ'></tfoot><dl id='VQSQZ'><fieldset id='VQSQZ'></fieldset></dl></div>
                          主站蜘蛛池模板: 91精品国产综合久久精品 | 欧美伊人久久久久久久久影院 | 美女视频. | 国产激情精品一区二区三区 | 日产精品久久久一区二区福利 | 久久伊人一区 | 国产清纯白嫩初高生视频在线观看 | 精久久久 | 国产乱码精品一区二区三区五月婷 | 亚洲狠狠 | 久久久久国产一区二区三区四区 | 伊色综合久久之综合久久 | 亚洲一区 | 中文字字幕一区二区三区四区五区 | 精品在线一区二区三区 | 秋霞av国产精品一区 | a级毛片免费高清视频 | 欧美激情视频一区二区三区在线播放 | 亚洲欧美一区二区三区情侣bbw | 日韩欧美精品 | 精品国产一区二区三区久久 | 成人av一区 | 一级片在线免费看 | jizz在线看片 | 综合二区| 97国产精品视频 | 亚洲一区二区三区四区五区中文 | 欧美精品久久久久 | 国产一级一级国产 | 高清国产一区二区 | 午夜精品一区二区三区在线观看 | 91在线观看视频 | 国产精品久久久久久久久免费樱桃 | 日本一区二区不卡 | 久久亚洲精品国产精品紫薇 | 午夜播放器在线观看 | 成人精品一区二区 | 91麻豆产精品久久久久久 | 午夜电影福利 | 国产精品国产精品国产专区不片 | 99伊人 |