w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
PHP analogue for JAVA TripleDES function

It seems that are not using the cipher in the same way. In your Java code, you are using an IV for your encryption, while you are not doing the same in your PHP code. That is because ECB, the mode you have specified in your PHP code, doesn't need any initialization, while whatever mode you are using in Java does.

What library are you using? As stated here here in the reference of Microsoft libraries that look very similar to the one you used with Java, the default encryption mode is CBC (which is generally considered more secure than ECB). It is very likely that CBC is being used in your library too.

You need to use the same mode of encryption if you want the same result. So, either set CBC (and the same IV you used in Java) in your PHP code, or use TripleDESCryptoServiceProvider to set the ECB mode in Java.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.