简体   繁体   English

System.Security.Cryptography.CryptographicException:'Cryptography_OAEPDecoding'

[英]System.Security.Cryptography.CryptographicException: 'Cryptography_OAEPDecoding'

i have a program that has to decrypt 3 phrases using a RSA privateKey but keeps showing that exception above, System.Security.Cryptography.CryptographicException: 'Cryptography_OAEPDecoding', what do i need to change for it to work?, i've tried seeing other pages but its too confusing, and i end up adding too many commented code and starting again.我有一个程序必须使用 RSA privateKey 解密 3 个短语,但一直显示上面的异常 System.Security.Cryptography.CryptographicException: 'Cryptography_OAEPDecoding',我需要改变什么才能让它工作?,我试过看到其他页面,但它太混乱了,我最终添加了太多注释代码并重新开始。

Exception that pops弹出的异常

The error occurs because you explicitly tell the RSA crypto service provider to use OAEP padding but your ciphers are encrypted using PKCS1 padding.发生错误是因为您明确告诉 RSA 加密服务提供商使用OAEP 填充,但您的密码是使用 PKCS1 填充加密的。

// Your current statement:
var decryptedBytes = rsa.Decrypt(resultBytes, true);

The second parameter (fOAEP is documented like:第二个参数(fOAEP 记录如下:

//   fOAEP:
//     true to perform direct System.Security.Cryptography.RSA decryption using
//     OAEP padding (only available on a computer running Microsoft Windows XP or
//     later); otherwise, false to use PKCS#1 v1.5 padding.

So by just changing to false;因此,只需更改为 false;

var decryptedBytes = rsa.Decrypt(resultBytes, false);

We get the following output:我们得到以下output:

INICIO DE LA SEGUNDA PARTE
M A N D A   C O R R E O   A   J A V I E R   B E L
C O N   T U   N O M B R E   C O M P L E T O
Y   L A   F E C H A / H O R A

Important side note:重要的旁注:

Probably while copy/pasting, your base64 ciphers are incorrect.可能在复制/粘贴时,您的 base64 密码不正确。 I corrected them like this:我这样纠正它们:

var FRASE1 = "IlmhPFKroDuK4AUtBGfaf5J6791DzMenkUBEXfRwZ7rmBHswHTf02LAba/Hs+rsh3wL6dpMQlEhlaIAVHaZZsw==";
var FRASE2 = "AMbsYR1pq9WYUj3mdqKvJj7tMznqBAcZLxM2C6WzNEUOqKD/qdEE76bNJPmYFKwVei2rhuHFsxh7nUzXmVKRdw==";
var FRASE3 = "J1jnq551phV+W4MVzE5caXIHqM3E0gz/t9PVtorqvDVqfne8CCF9UQiEk33Rssi1IEz6JH8Fd8ZAvnX3UWe5Vw==";

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.Security.Cryptography.CryptographicException:参数不正确 - System.Security.Cryptography.CryptographicException: The parameter is incorrect TwilioRequestValidator 中的瞬态 System.Security.Cryptography.CryptographicException - Transient System.Security.Cryptography.CryptographicException in TwilioRequestValidator System.Security.Cryptography.CryptographicException:句柄无效 - System.Security.Cryptography.CryptographicException: The handle is invalid System.Security.Cryptography.CryptographicException:系统找不到指定的文件 - System.Security.Cryptography.CryptographicException: The system cannot find the file specified 加密连接字符串时出现System.Security.Cryptography.CryptographicException - System.Security.Cryptography.CryptographicException upon encrypting connectionstring w3wp.exe中发生了System.Security.Cryptography.CryptographicException” - System.Security.Cryptography.CryptographicException" occurred in w3wp.exe 重置Microsoft Identity上的密码会导致System.Security.Cryptography.CryptographicException - Resetting password on Microsoft Identity causes System.Security.Cryptography.CryptographicException System.Security.Cryptography.CryptographicException:密钥集不存在 - System.Security.Cryptography.CryptographicException: keyset does not exist PrivateKey抛出了System.Security.Cryptography.CryptographicException类型的异常 - PrivateKey threw an exception of type System.Security.Cryptography.CryptographicException System.Security.Cryptography.CryptographicException:'输入数据不是一个完整的块。' - System.Security.Cryptography.CryptographicException: 'The input data is not a complete block.'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM