Private Staticfinal Cipher Des_cipher;Static { Try{Des_cipher= Cipher.getinstance ("desede/ecb/pkcs5padding"); } Catch(NoSuchAlgorithmException |nosuchpaddingexception e) { Throwthrowables.propagate (e); }} Public Staticstring Encryptdes (String encryptstring, String encryptkey) {Try {Des_cipher.init (Cipher.encrypt_mode,NewSecretkeyspec (Encryptkey.getbytes (ICBCBINDCONSTANT.ENCODING_GBK),"Desede")); byte[] EncryptedData =des_cipher.dofinal (Encryptstring.getbytes (ICBCBINDCONSTANT.ENCODING_GBK)); String Hexdata=hex.encodehexstring (EncryptedData). toUpperCase (); returnStringutils.leftpad (String.valueof (Hexdata.length ()),6,'0') +Hexdata; } Catch(Throwable e) {Throwthrowables.propagate (e); }} Public Staticstring Decryptdes (String decryptstring, String decryptkey) {Try {Des_cipher.init (Cipher.decrypt_mode,NewSecretkeyspec (Decryptkey.getbytes (ICBCBINDCONSTANT.ENCODING_GBK),"Desede")); byte[] Decrypteddata = Des_cipher.dofinal (Hex.decodehex (decryptstring.substring (6). ToCharArray ())); return NewString (Decrypteddata, ICBCBINDCONSTANT.ENCODING_GBK); } Catch(Throwable e) {Throwthrowables.propagate (e); }}
Java Desede plus decryption ("desede/ecb/pkcs5padding")