java desede_java.security.InvalidKeyException: Wrong algorithm: DESede or TripleDES required

(65) 2024-04-24 20:01:01

I wrote this code, my key is: "ooWqEPcw7KR/h/JIbrFCRHiEVaybvnB2".

try

{

Base64Decoder base64Decoder=new Base64Decoder();

String encryptType="DESede/ECB/PKCS5Padding";

String workingKey="ooWqEPcw7KR/h/JIbrFCRHiEVaybvnB2";

SecretKey secretKey=new SecretKeySpec(base64Decoder.decode(workingKey), encryptType);

Cipher cipher=Cipher.getInstance(encryptType);

cipher.init(1, secretKey);

}

catch(NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException e)

{

e.printStackTrace();

}

But I get this error!!!

java.security.InvalidKeyException: Wrong algorithm: DESede or TripleDES required

at com.sun.crypto.provider.DESedeCrypt.init(DESedeCrypt.java:65)

at com.sun.crypto.provider.ElectronicCodeBook.init(ElectronicCodeBook.java:93)

at com.sun.crypto.provider.CipherCore.init(CipherCore.java:582)

at com.sun.crypto.provider.CipherCore.init(CipherCore.java:458)

at com.sun.crypto.provider.DESedeCipher.engineInit(DESedeCipher.java:166)

at javax.crypto.Cipher.implInit(Cipher.java:802)

at javax.crypto.Cipher.chooseProvider(Cipher.java:864)

at javax.crypto.Cipher.init(Cipher.java:1249)

at javax.crypto.Cipher.init(Cipher.java:1186)

at EncryptText.main(EncryptText.java:24)

THE END

发表回复