public static String encrypt ( String data , String key ) { try { Cipher c = Cipher . getInstance ( "DES/ECB/PKCS5Padding" ) ; c . init ( Cipher . ENCRYPT_MODE , SecretKeyFactory . getInstance ( "DES" ) . generateSecret ( new DESKeySpec ( key . getBytes ( ) ) ) ) ; return Hex . encodeHexString ( c . doFinal ( data . getBytes ( ) ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return null ; }
Convert data to encrypted hex string