1
$\begingroup$

I am a bit new at cryptography, I tried to recover data from an old app database, I got the key and the type of encryption, it says "AES/CBC/PKCS5Padding", I used this online tool http://8gwifi.org/CipherFunctions.jsp to decrypt some strings, it decrypted but I got some characters at the beginning of my data, for example:

2cjABhgd?????samsung

?9??kj`?D g?GALAXY S5

In that case I should only get "samsung" and "GALAXY S5", but for some reason I get characters at the beginning. I want to know why this happens and how can I automatically get rid off those characters of the beginning, because I have hundreds of lines of data that decrypts like this.

$\endgroup$
3
$\begingroup$

If the data at the beginning is exactly 16 characters long every time, then it is certainly the initialization value for the CBC mode, and you can simply cut them off and output the valid data starting at byte 17.

My guess is that because that web decoder provides no specific input for the IV, it does not attempt to truncate the prefix itself, and simply outputs all the data, letting you decide what to do with it.

$\endgroup$
  • 2
    $\begingroup$ To be precise, we're talking about 16 bytes of IV, since characters can have variable length in certain encodings. $\endgroup$ – CodesInChaos Dec 13 '16 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.