Decryption code error using Vb.net!

Asked

Viewed 162 times

3

I’m having trouble decrypting with the code below that I found on the net:

Código de Encriptação e Descriptação com VB.net Criptografa

When debugging you can see that in the property TripleDES.Key has the value 16 in length and the Buffer 15, is that why? How to solve?

I don’t know anything about encryption, I got this code off the Internet. Descriptografa

  • 1

    Was this Buffer encrypted as? With the function Criptografa above? The fact that CT has different key size is no problem, but still it is quite strange a 15 bytes CT... Maybe it lacked a padding, I don’t know. (P.S. never, never use ECB in practice, is terribly insecure! Use an authenticated encryption mode such as GCM, CCM, etc., or otherwise CBC or CTR along with a MAC. And 3DES is not bad, but AES gives more security, if possible use this. Finally, this key derivation method - MD5 from a password - is not good, I suggest PBKDF2 instead).

  • Thanks for the advice. was encrypted by the above method yes. I detected the problem, it happens that when encrypting in my project Asp.net, it is saving only 20 characters, and the encrypted code has more than 20 characters. no matter the size of the password I type, it always saves 20 characters in the database. And that’s not what happens in my other application with the same code in windows form. I just couldn’t find the reason why. My column in the bank is 200 characters long.

  • Cod encrypted in the windows form application Jfyvjvdep2yzpc2ky/wnXA==............................................ And the Cod generated in the webform application Jfyvjvdep2yzpc2ky/wn

  • 2

    Could post code instead of images? It is very bad to view these images on smaller screen devices.

  • 2

    I agree with @re22, and it’s even harder to test your code if we can’t copy and paste (as an image, all we have to do is type it all over again...)

  • Most likely is a problem of padding same. See this test on ideone: I tried to decrypt the correct code and it gave "padding invalid". This means that the padding pattern . Net is using is different from padding used by your original application. Find out what this is padding. (P.S. If it’s not a problem of padding, is problem of encoding. Its original string had accents? That other test encrypted and decrypted correctly, using only ASCII).

  • 1

    Guys I was able to fix, the problem was in my file, the variable @password was set as varchar 20, so save-go only 20 characters. Silly thing more than earned a while here kkk. Thanks to those who are willing to help me!!

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.