Fix Rijndael Invalid Length for a Base-64 Char Array
I have a requirement to send a variable from a link to a page. But the variable should be encrypted. And md5 will not work because I'm u...
https://www.czetsuyatech.com/2011/03/java-troubleshooting-rijndael-invalid-length.html
I have a requirement to send a variable from a link to a page. But the variable should be encrypted. And md5 will not work because I'm using entity framework and it doesn't recognized the md5 function.
So I implement encryption using Rijndael. I downloaded the class from microsoft and it's working properly in my test cases. So I immediately put it on my web page, but from time to time I got the error above. Note that I already encoded/decoded the variable. What I noticed is that the '+' character is being replaced by a space, weird. I don't have any explanation to this. So what I did was simply revert back ' ' to '+' character, as shown in the following code:
So I implement encryption using Rijndael. I downloaded the class from microsoft and it's working properly in my test cases. So I immediately put it on my web page, but from time to time I got the error above. Note that I already encoded/decoded the variable. What I noticed is that the '+' character is being replaced by a space, weird. I don't have any explanation to this. So what I did was simply revert back ' ' to '+' character, as shown in the following code:
var s = HttpUtility.UrlDecode(Request.QueryString["param"]); s = s.Replace(" ", "+"); var id = Rijndael.DecryptStringAes(s);
Post a Comment