2022年9月记录(AES加密,忽略SSL过期,webservice示例,注解@Async的使用)

1.AES加密

参考Java 中的加密算法: AES - 知乎

    public static byte[] encryptECB(byte[] data, byte[] key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"));
        byte[] result = cipher.doFinal(data);
        return result;
    }

    public static byte[] decryptECB(byte[] data, byte[] key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"));
        byte[] result = cipher.doFinal(data);
        return result;
    }

//    public static void main(String[] args) throws IllegalBlockSizeException, InvalidKeyException, BadPaddingException, NoSuchAlgorithmException, NoSuchPaddingException {
//        String data = "123"; // 待加密的明文
//        String key = "11abcdef11abcdef"; // key 长度只能是 16、24 或 32 字节
//
//        byte[] ciphertext = encryptECB(data.getBytes(), key.getBytes());
//        System.out.println("ECB 模式加密结果(Base64):" + Base64.getEncoder().encodeToString(ciphertext));
//
//        byte[] plaintext = decryptECB(ciphertext, key.getBytes());
//        System.out.println("解密结果:" + new String(plaintext));
//    }
    public static byte[] encryptCBC(byte[] data, byte[] key, byte[] iv) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException {
        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
        cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"), new IvParameterSpec(iv));
        byte[] result = cipher.doFinal(data);
        return result;
    }

    public static byte[] decryptCBC(byte[] data, byte[] key, byte[] iv) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException {
        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
        cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"), new IvParameterSpec(iv));
        byte[] result = cipher.doFinal(data);
        return result;
    }

    public static void main(String[] args) throws IllegalBlockSizeException, InvalidKeyException, BadPaddingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException {
        String data = "Hello World"; // 待加密的原文
        String key = "12345678abcdefgh"; // key 长度只能是 16、24 或 32 字节
        String iv = "iviviviviviviviv"; // CBC 模式需要用到初始向量参数

        byte[] ciphertext = encryptCBC(data.getBytes(), key.getBytes(), iv.getBytes());
        System.out.println("CBC 模式加密结果(Base64):" + Base64.getEncoder().encodeToString(ciphertext));

        byte[] plaintext = decryptCBC(ciphertext, key.getBytes(), iv.getBytes());
        System.out.println("解密结果:" + new String(plaintext));
    }

2.netty总结

https://www.jianshu.com/p/0d20c97a45e5

LengthFieldBasedFrameDecoder

3.LambdaQueryWrapper实现原理和lambda序列化(IT技术)

4.Mybatis Plus动态代理源码分析 - MalcolmFeng - 博客园 

5.HttpClient4.2.1忽略https中的SSL证书失效 - 张汉生 - 博客园

6.SpringBoot集成Axis2,部署webservice接口并调用_吃瓜~的博客-CSDN博客_axis springboot 

SpringBoot2 整合 AXIS2 服务端和客户端_gblfy的博客-CSDN博客_springboot使用axis2

7.注解@Async的使用 - 知乎 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值