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,029
  • 10
  • 29
  • 61

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
  • 84,836
  • 13
  • 136
  • 244
Tapa Save
  • 4,543
  • 4
  • 31
  • 53
-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,781
  • 3
  • 25
  • 47
Yuriy
  • 1