• (Java) AES-128 数据加密


    package com.vcgeek.hephaestus.utils;
    
    import javax.crypto.Cipher;
    import javax.crypto.spec.SecretKeySpec;
    
    
    public class AESUtil {
    
        //  AES-128 数据加密的 JAVA 实现
        public static byte[] Encrypt(byte[] sSrc, byte[] sKey){
            try{
                SecretKeySpec skeySpec = new SecretKeySpec(sKey, "AES");
                Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
                cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
                byte[] encrypted = cipher.doFinal(sSrc);
                return encrypted;
            }catch(Exception ex){
                return null;
            }
        }
    
        //  AES-128 数据解密的 JAVA 实现
        public static byte[] Decrypt(byte[] sSrc, byte[] sKey){
            try{
                SecretKeySpec skeySpec = new SecretKeySpec(sKey, "AES");
                Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
                cipher.init(Cipher.DECRYPT_MODE, skeySpec);
                byte[] dncrypted = cipher.doFinal(sSrc);
                return dncrypted;
            }catch(Exception ex){
                return null;
            }
        }
    
    }
  • 相关阅读:
    nginx 转发配置
    Rancher中httpd证书的管理和使用
    JDK-docker
    软路由
    rancher相关
    rancher部署
    电商 好文 知识积累
    SpringBlade 接口文档 请求token接口报错
    SpringBlade 接口文档 无法访问
    电商 好文
  • 原文地址:https://www.cnblogs.com/zyulike/p/10573299.html
Copyright © 2020-2023  润新知