The built-in signature algorithm for the JDK does not contain the needs of the applet (the algorithm used for symmetric decryption is AES-128-CBC, the data is populated with pkcs#7), so a third-party jar needs to be referenced.
Compile group: ' Org.bouncycastle ', Name: ' Bcprov-jdk15on ', version: ' 1.54 '
The following is the specific code:
//assign a value to a constructor by itselfString SessionKey;/*** AES-128-CBC decryption * Using PKCS fills *@paramEncryptedData *@paramIV *@return * @throwsException*/ PublicString Decryptaespkcdata (String EncryptedData, String IV)throwsException {//Check the length of the SessionKey if( This. sessionkey.length ()! = 24) { Throw Newaesexception (Aesexception.illegalaeskey); } //Check the length of IV if(Iv.length ()! = 24) { Throw Newaesexception (Aesexception.illegalaeskey); } byte[] Aeskey = Base64.decodebase64 ( This. SessionKey); byte[] Aesiv =Base64.decodebase64 (iv); byte[] Aescipher =base64.decodebase64 (EncryptedData); Security.addprovider (NewOrg.bouncycastle.jce.provider.BouncyCastleProvider ()); Cipher Cipher= Cipher.getinstance ("aes/cbc/pkcs7padding"); Key Skeyspec=NewSecretkeyspec (Aeskey, "AES"); Algorithmparameters params= Algorithmparameters.getinstance ("AES"); Params.init (NewIvparameterspec (Aesiv)); Cipher.init (Cipher.decrypt_mode, Skeyspec, params); return NewString (Cipher.dofinal (Aescipher), "Utf-8"); }
Small program Data signature check-java end