import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.spec.GCMParameterSpec;
import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.security.SecureRandom;
import java.security.Security;
import java.util.Set;
public class AES256GCMUtil {
private final static String ALGO = "AES_256/GCM/NOPADDING";
public static final int AES_KEY_SIZE = 256;
public static final int GCM_IV_LENGTH = 12;
public static final int TLEN = 128;
static {
Set<String> algorithms = Security.getAlgorithms("Cipher");
if (!algorithms.contains(ALGO)) {
throw new IllegalArgumentException("AES256 encrypt and decrypy system can not used");
}
}
public static void main(String[] args) throws Exception {
/* Check Option Format.Option or parameters must is true then process next code*/
if(args.length == 0) {
System.out.println("Option error!You need
AES-256-GCM Java实现
最新推荐文章于 2025-11-01 16:57:17 发布
博客介绍了将代码保存为AES256GCMUtil.java文件后,在对应目录通过命令行操作的方法。包括 -e 加密需原文和密钥两个参数,-d 解密需密文和密钥两个参数。还提到伽罗瓦计数器模式的AES算法加密后密文不一致,但解密会删除随机数。

最低0.47元/天 解锁文章
451

被折叠的 条评论
为什么被折叠?



