Detecting incorrect key using AES/GCM in JAVA

前端 未结 2 791
悲&欢浪女
悲&欢浪女 2021-01-01 06:52

I\'m using AES to encrypt/decrypt some files in GCM mode using BouncyCastle.
While I\'m proving wrong key for decryption there is no exception.

2条回答
  •  别那么骄傲
    2021-01-01 07:17

    You are using NoPadding. Change this to PKCS7Padding for both encryption and decryption. If the wrong key is used then the padding will almost certainly fail to decrypt as expected and an InvalidCipherTextException will be thrown.

提交回复
热议问题