输入不是有效的基本-64字符串,因为它包含一个非基本64个字符,超过两个填充字符,

发布于 2025-02-13 22:09:59 字数 1002 浏览 0 评论 0原文

这是我使用的代码。当我本地运行时,它可以正常工作。但是,当我将所有DLL放到远程计算机上时,我会一直遇到此错误:

输入不是有效的基本-64字符串,因为它包含一个非基础64个字符,超过两个填充字符或填充中的非法字符人物。

   public static string Decrypt(string cipherText)
    {
        if (cipherText == string.Empty)
            return string.Empty;

        byte[] cipherBytes = Convert.FromBase64String(cipherText);
        PasswordDeriveBytes pdb = new PasswordDeriveBytes(
            new byte[] { 0x50, 0x00, 0x41, 0x00, 0x43, 0x00, 0x43, 0x00, 0x41, 0x00, 0x52, 0x00, 0x34, 0x00, 0x32, 0x00,
                0x35, 0x00, 0x34, 0x00, 0x36, 0x00, 0x38, 0x00, 0x37, 0x00, 0x34, 0x00, 0x30, 0x00, 0x30, 0x00, },
            new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
        byte[] decryptedData = Decrypt(cipherBytes, pdb.GetBytes(32), pdb.GetBytes(16));
        
        return System.Text.Encoding.Unicode.GetString(decryptedData);
    }

有人可以帮我弄清楚吗?我有检查机器,看来机器的NET 4.5及更高。我已经在.NET 4.0上构建了我的应用程序。除此之外,我无法弄清楚错误在哪里

Here is the code i am using. It works fine when i run locally. but when i drop all my dlls to a remote machine i keep getting this error:

The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

   public static string Decrypt(string cipherText)
    {
        if (cipherText == string.Empty)
            return string.Empty;

        byte[] cipherBytes = Convert.FromBase64String(cipherText);
        PasswordDeriveBytes pdb = new PasswordDeriveBytes(
            new byte[] { 0x50, 0x00, 0x41, 0x00, 0x43, 0x00, 0x43, 0x00, 0x41, 0x00, 0x52, 0x00, 0x34, 0x00, 0x32, 0x00,
                0x35, 0x00, 0x34, 0x00, 0x36, 0x00, 0x38, 0x00, 0x37, 0x00, 0x34, 0x00, 0x30, 0x00, 0x30, 0x00, },
            new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
        byte[] decryptedData = Decrypt(cipherBytes, pdb.GetBytes(32), pdb.GetBytes(16));
        
        return System.Text.Encoding.Unicode.GetString(decryptedData);
    }

Can someone please help me figure out? i have check the machine and it seems that machine has .NET 4.5 and higher. and I have built my application on .Net 4.0. Other than that i am not able to figure out where is the error

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文