Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The data to be decrypted exceeds the maximum for this modulus of 256 bytes.


What I have tried:

Public Function Decrypt(ByVal encryptedText As String, ByVal cert As X509Certificate2) As String
       Try

           Dim privateKey As RSACryptoServiceProvider = CType(cert.PrivateKey, RSACryptoServiceProvider)

           Dim encryptedBytes As Byte() = Convert.FromBase64String(encryptedText)
           Dim decryptedBytes As Byte() = privateKey.Decrypt(encryptedBytes, True)
           Dim decryptedText As String = Encoding.UTF8.GetString(decryptedBytes)
           Return decryptedText

       Catch ex As Exception

       End Try
Posted
Updated 30-Dec-19 12:06pm
v2
Comments
F-ES Sitecore 18-Dec-19 7:02am    
Google the error message to get an idea what might be wrong, or look for examples of how to use RSACryptoServiceProvider and try and get some sample code working, then adapt to what you are doing.

Check out Blowfish might be a better encryption option.
 
Share this answer
 
You might be interested in this CodeProject article: Swanky Encryption/Decryption in C#[^]
Quote:
can easily handle with my implementation is to split a 50GB file into a series of smaller files with 100MB data each in one go
 
Share this answer
 
If you don't understand an error message, Google it: The data to be decrypted exceeds the maximum for this modulus of 256 bytes. - Google Search[^]
Loads of people have met this before, and every link on the first page tells you the same thing: the data is too long to be encrypted with RSA, you need to use AES or Triple-DES
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900