0

I am developing an android application in which it is necessary to decrypt the file. I specify an algorithm as follows:

Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding", "Crypto");

But get the error:

java.security.NoSuchAlgorithmException: AES/ECB/PKCS5Padding

What is my mistake?

Thanks.

Mark Korzhov
  • 2,109
  • 11
  • 31
  • 63

2 Answers2

3

Try and use

 Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");

If you don't specify the provider, it will look for the highest prioritized provider that does implement it.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
Tapa Save
  • 4,769
  • 5
  • 32
  • 54
-3

Define the exception handler. You need to add the proper import in the begging of your class, like this:

import java.security.NoSuchAlgorithmException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.Cipher; 

Look here how

ekostadinov
  • 6,880
  • 3
  • 29
  • 47
Yuriy
  • 1