private String aes128WithFirst16Char ( String content , String privateKey ) throws GeneralSecurityException { byte [ ] crypted = null ; SecretKeySpec skey = new SecretKeySpec ( privateKey . substring ( 0 , 16 ) . getBytes ( ) , "AES" ) ; Cipher cipher = Cipher . getInstance ( "AES/ECB/PKCS5Padding" ) ; cipher . init ( Cipher . ENCRYPT_MODE , skey ) ; crypted = cipher . doFinal ( content . getBytes ( ) ) ; return new String ( Hex . encodeHex ( crypted ) ) ; }
The encryption implement for AES - 128 algorithm for BCE password encryption . Only the first 16 bytes of privateKey will be used to encrypt the content .