Fala galera!
Estou tendo problemas com uma classe de criptografia. Quando chamo o método encrypt() eu recebo um 'java.security.NoSuchAlgorithmException:Cannot find any provider supporting AES/CBC/PKCS5Padding'
Segue o código do método:
public static String encrypt(String text, String password) throws Exception
{
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
//setup key
byte[] keyBytes = new byte[16];
byte[] b = password.getBytes("UTF-8");
int len = b.length;
if (len > keyBytes.length) len = keyBytes.length;
System.arraycopy(b, 0, keyBytes, 0, len);
SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
//the below may make this less secure, hard code byte array the IV in both java and .net clients
IvParameterSpec ivSpec = new IvParameterSpec(keyBytes);
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec);
byte[] results = cipher.doFinal(text.getBytes("UTF-8"));
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(results);
}
Imagino que esteja faltando alguma dependência. O que poderia ser?