【问题标题】:How can I decrypt a string using AES algorithm in c#?如何在 c# 中使用 AES 算法解密字符串?
【发布时间】:2010-07-12 08:15:25
【问题描述】:

我有一个来自我们一位客户的加密字符串。
该字符串是使用 Java 中的 AES 方法加密的。

我唯一拥有的是密钥:“xxxxxxxxxxxxxxxxxxxxxxxx”(24 个字符)和加密文本:“56e84e9f6344826bcfa439cda09e5e96”(32 个字符)。 (这确实是我唯一的数据)

我似乎找不到解密这个字符串的方法。

谁能给我一个可行的例子。

【问题讨论】:

    标签: c# aes encryption rijndaelmanaged


    【解决方案1】:

    这里有两个完整的代码示例:

    您可能还会发现c# implementations of AES encryption 非常有趣。

    我发现了另一个例子Simple encrypting and decrypting data in C#,他们只使用密码短语来解密。

    【讨论】:

    • 在这些示例中,您需要: public static string Decrypt(string cipherText, string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations, string initVector, int keySize) 我只有前 2 个
    • @Sem,afaik 你需要所有这些才能解密它。因为那些是你加密时使用的。
    • 这些解决方案不起作用,我收到一个错误:“无效的数据长度”问题出在:byte[] cipherBytes = Convert.FromBase64String(cipherText);如果我通过使用 assci 编码将其更改为 bytearray 我没有收到错误,但是我收到的文本肯定不可读
    • @Sem,您是否有任何示例数据可以在您知道输入和输出的地方使用?那样会更容易尝试。
    • 你也看过这个问答吗? stackoverflow.com/questions/2994235/…
    【解决方案2】:

    请阅读这篇文章“Simple Cryptographer - Simple DES/AES Implementation in C#”

    链接:http://www.codeproject.com/KB/recipes/Simple_Cryptographer.aspx

    希望这篇文章对你有所帮助。

    【讨论】:

    • 虽然这在理论上可以回答这个问题,it would be preferable 在此处包含答案的基本部分,并提供链接以供参考。
    猜你喜欢
    • 2014-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-06
    • 2017-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多