puzhibing
2023-08-16 d5b3e5a413bcfccba294793ee093722f31b2448a
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/AESUtils.java
@@ -27,16 +27,16 @@
     * @param context
     * @return
     */
    public static String encrypt(String context) {
        try {
            byte[] decode = context.getBytes(CHARSET);
            byte[] bytes = createKeyAndIv(decode, Cipher.ENCRYPT_MODE);
            return Base64.getEncoder().encodeToString(bytes);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
//    public static String encrypt(String context) {
//        try {
//            byte[] decode = context.getBytes(CHARSET);
//            byte[] bytes = createKeyAndIv(decode, Cipher.ENCRYPT_MODE);
//            return Base64.getEncoder().encodeToString(bytes);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return null;
//    }
    /**
     * 解密
@@ -96,9 +96,9 @@
    public static void main(String[] args) {
        String context = "zhaors";
        System.out.println("元数据" + context);
        String encrypt = encrypt(context);
        System.out.println("加密之后:" + encrypt);
        String decrypt = decrypt(encrypt);
        System.out.println("解密之后:" + decrypt);
//        String encrypt = encrypt(context);
//        System.out.println("加密之后:" + encrypt);
//        String decrypt = decrypt(encrypt);
//        System.out.println("解密之后:" + decrypt);
    }
}