I have a problem with AES encryption and the customer showed me their PHP server code for “decrypting”. Curiously enough the exact code has been taken from S.O. (not surprising). I found this out because the code the customer passed me had the exact same comment! 🙂
Anyway, it’s a piece of PHP code taken from this S.O. question.
I am trying to do the same with Java but I don’t know what this exact line is adding:
$key = 'a16byteslongkey!';
$padded_key = $key . str_repeat(chr(0x00), 16); // Argh!
(note the // Argh! comment was not mine 😉
Is it trying to add chr(0x00) to make a 32 bytes key (because the $key is 16?) if so, how would I do the same in Java?
As Gareth stated this returns the character with ASCII code 0. Using this we can make a function which repeats a string:
Now the line can be replaced with: