Ad
Java.security.NoSuchAlgorithmException: Provider SunJCE Does Not Provide DES/ECB/NoPadding
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
byteKey=Hex.decodeHex("abcdef0123456789".toCharArray());
Log.d("aabb","byteKey:"+byteKey);
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 ...
Ad
Answer
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.
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad