Skip to content

Org.BouncyCastle.Crypto.DataLengthException: attempt to process message to long for cipher #591

Closed Answered by peterdettman
jaskcdem asked this question in Q&A
Discussion options

You must be logged in to vote

The problem is in CryptographyHelper:

    public string Decrypt(string encryptData) => Encoding.UTF8.GetString(Crypto.Decrypt(Encoding.UTF8.GetBytes(encryptData)));

The encryptData that is passed to this method is in Base64 encoding, so it should be decoded from Base64 instead of UTF8:

    public string Decrypt(string encryptData) => Encoding.UTF8.GetString(Crypto.Decrypt(Convert.FromBase64String(encryptData)));

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@jaskcdem
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by jaskcdem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants