Ad Provider SunJCE Does Not Provide DES/ECB/NoPadding

- 1 answer

I am trying to decrypt data using org.jpos JCEHandler in Android like below code

public static byte[] decrypt(byte[] data, byte[] key, String algorithm) throws JCEHandlerException
    byte[] plainText;
    JCEHandler handler = new JCEHandler("com.sun.crypto.provider.SunJCE");
    SecretKeySpec secretKeySpec = new SecretKeySpec(key, algorithm);
    plainText = handler.decryptData(data, secretKeySpec);
    return plainText;

but it catch Exception says Provider SunJCE does not provide DES/ECB/NoPadding

I call this function like below code

TMK = Hex.decodeHex("abcdef0123456789".toCharArray());
byteKey = Crypto.decrypt(byteKey,TMK,"DES");

the log of byteKey is : [[email protected]

what should I do , I try a lot to solve it but always same error , can I find some codes do the same result of handler.decryptData in android can I find any help please ...



JCEHandler handler = new JCEHandler("com.sun.crypto.provider.SunJCE");

You are enforcing JCE provider to use SunJCE which may not have the corresponding crypto implementation for DES/ECB/NoPadding, you can either try other algo or use SpongyCastle as your security provider.

Update:ECB mode is already proved to be weak, you should NOT use ECB mode.