0

I am new to Java. I followed this tutorial about Encryption and Decryption using 3DES algorithm.

I have implemented like this:

  1. Created a class and placed the 3DES code provided in the above link.
  2. Called the encrypt method in the above link as below:

    String encryptedPassword = Encrypter.encrypt(edtText.getText().toString()); 
    

I am getting the exception in logcat as below:

 05-02 15:19:10.804: W/System.err(4445): java.security.NoSuchProviderException: Provider not available: SunJCE
    05-02 15:19:10.820: W/System.err(4445):     at javax.crypto.Cipher.getInstance(Cipher.java:209)
    05-02 15:19:10.820: W/System.err(4445):     at com.example.utilities.Encrypter.encrypt(Encrypter.java:46)
    05-02 15:19:10.820: W/System.err(4445):     at com.example.screens.RegisterScreen.onClick(RegisterScreen.java:152)
    05-02 15:19:10.820: W/System.err(4445):     at android.view.View.performClick(View.java:2485)
    05-02 15:19:10.820: W/System.err(4445):     at android.view.View$PerformClick.run(View.java:9080)
    05-02 15:19:10.828: W/System.err(4445):     at android.os.Handler.handleCallback(Handler.java:587)
    05-02 15:19:10.828: W/System.err(4445):     at android.os.Handler.dispatchMessage(Handler.java:92)
    05-02 15:19:10.828: W/System.err(4445):     at android.os.Looper.loop(Looper.java:130)
    05-02 15:19:10.828: W/System.err(4445):     at android.app.ActivityThread.main(ActivityThread.java:3687)
    05-02 15:19:10.835: W/System.err(4445):     at java.lang.reflect.Method.invokeNative(Native Method)
    05-02 15:19:10.835: W/System.err(4445):     at java.lang.reflect.Method.invoke(Method.java:507)
    05-02 15:19:10.835: W/System.err(4445):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
    05-02 15:19:10.835: W/System.err(4445):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
    05-02 15:19:10.835: W/System.err(4445):     at dalvik.system.NativeStart.main(Native Method)

Please help me. How to solve this....

Avadhani Y
  • 7,566
  • 19
  • 63
  • 90
user2326860
  • 1
  • 1
  • 4
  • 12

1 Answers1

0

Sorry, I was being lazy. The line

Cipher ecipher = Cipher.getInstance("DESede/CBC/PKCS5Padding","SunJCE");

shows that you are specifying a particular provider. Normally you would want a very good reason for doing this, for example you might be required to use a FIPS-compliant provider. The SunJCE provider does not exist on Android. Just use the default provider, which you get simply by leaving out that argument. So try:

Cipher ecipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");

Similarly, change

Cipher dcipher = Cipher.getInstance("DESede/CBC/PKCS5Padding","SunJCE");

to

Cipher dcipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
President James K. Polk
  • 40,516
  • 21
  • 95
  • 125