so I encrypted a string on my php server.
encrypt("http://google.com", "happy");
function encrypt($str, $key)
{
$block = mcrypt_get_block_size('des', 'ecb');
$pad = $block - (strlen($str) % $block);
$str .= str_repeat(chr($pad), $pad);
return mcrypt_encrypt(MCRYPT_DES, $key, $str, MCRYPT_MODE_ECB);
}
btw, this returns some weird string…I was expecting letters and numbers:
ZöÞ ÔP»8
Back on Java, I need to decrypt this string with the key.
This may help for MCrypt in java:
http://www.java2s.com/Open-Source/Java-Document/EJB-Server/resin-4.0.7/com/caucho/quercus/lib/mcrypt/Mcrypt.java.htm
Another link:
http://www.kanatorn.info/2011/11/07/aes-encrypt-decrypt-between-java-php/