java - How to increase the mcrypt-generic-init key size from 8 to 16? -
When I run encryption, I get an error: Warning: mcrypt_generic_init () [function.mcrypt-generic - init]: The size of the key is too large; Supply Length: 16, Max: 8 My code: I'm trying to write an encryption & amp; Decryption between Java (code provided by Java developer) & amp; PHP. But Java only supports 16 characters. Thank you. You can not DEE encryption key length supports 56bit (7 characters), block size 64 Bit (8 characters). More characters are useless, I do not know how long the operation Java is, but it gets smaller in some way. I would ask if the Java program uses DES or Triple-DES encryption. Triple-DES uses 168 bit key length so that you can use the keys with 16 characters. Some side notes- DES is considered unsafe, so I hope Triple-DES is used.
$ size = mcrypt_get_block_size ('des', 'ecb'); $ Input = pkcs5_pad ($ input, $ size); $ Key = '* 5hS7e6 $ 23 n # 2m7s'; $ Td = mcrypt_module_open ('des', '', 'ecb', ''); $ iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($ td), MCRYPT_RAND); Mcrypt_generic_init ($ td, $ key, $ iv); $ Data = mcrypt_generic ($ td, $ input); Mcrypt_generic_deinit ($ TD); mcrypt_module_close ($ TD); $ Data = base 64_ode ($ data); $ Return data;
Comments
Post a Comment