1

我需要使用另一家公司公开的网络服务。

他们告诉我在 OFB 模式下使用 Rijndael 来加密我发送给他们的数据,但显然,.Net (3.5) 不支持 Rijndael 的 OFB。它告诉我:(System.Security.Cryptography.CryptographicException: the (crypting?) mode is not valid for this algorithm近似即时翻译)。

他们给了我一个 32 个字母数字字符的 IV。我不能使用它(使用System.Text.Encoding.ASCII.GetBytes(k)),它告诉我:(System.Security.Cryptography.CryptographicException: the specified initialization vector (IV) does not match the block size for this algorithm近似即时翻译)。密钥与 IV 的长度相同,并且可以正常工作。

我该怎么做才能让它发挥作用?

谢谢

4

1 回答 1

3

您可以使用 CBC 模式通过将 CBC 方法全为 0 作为纯文本输入来生成 OFB 输出。然后使用您的真实明文手动异或接收到的密钥流。实际上,维基百科上的图表很好地展示了它是如何工作的,看这里

于 2011-04-06T11:17:03.243 回答