Java AES encryption and decryption

后端 未结 6 1415
独厮守ぢ
独厮守ぢ 2020-12-07 15:48

I would like to encrypt and decrypt a password using 128 bit AES encryption with 16 byte key. I am getting javax.crypto.BadPaddingException error while decrypt

6条回答
  •  余生分开走
    2020-12-07 16:38

    Try this, a simpler solution.

    byte[] salt = "ThisIsASecretKey".getBytes();
    Key key = new SecretKeySpec(salt, 0, 16, "AES");
    
    Cipher cipher = Cipher.getInstance("AES");
    

提交回复
热议问题