• java加密算法-AES


    public class AESUtil {
        public static void main(String[] args){
            jdkAES("12345623423432423S");
        }
        public static void jdkAES(String str){
            try {
            SecureRandom random = new SecureRandom();
            byte[] salt = random.generateSeed(8);
            PBEKeySpec pkey=new PBEKeySpec(str.toCharArray());
                SecretKeyFactory factory = SecretKeyFactory.getInstance("PBEWITHMD5andDES");
                Key key = factory.generateSecret(pkey);
                Key key2 = factory.generateSecret(pkey);
            
                System.out.println("KEY:"+key.serialVersionUID);
                System.out.println("KEY2:"+key2.serialVersionUID);
            
            PBEParameterSpec pbets = new PBEParameterSpec(salt,100);
            Cipher c = Cipher.getInstance("PBEWITHMD5andDES");
            c.init(Cipher.ENCRYPT_MODE, key,pbets);
            byte[] result = c.doFinal(str.getBytes());
            System.out.println(Base64.encodeBase64String(result));
            
            
            c.init(Cipher.DECRYPT_MODE, key,pbets);
            result = c.doFinal(result);
            System.out.println(new String(result));
            
            
            
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        
    }
  • 相关阅读:
    正则表达式
    9.4、分布式进程
    Linux文件编辑工具——VIM
    14 Linux网络管理
    13.Linux系统服务
    12.Linux进程管理
    11.Linux磁盘管理——lvm,raid
    10.Linux磁盘管理
    09.Linux软件包管理——(YUM 、RPM)
    07.Linux 压缩打包
  • 原文地址:https://www.cnblogs.com/syscn/p/7742262.html
Copyright © 2020-2023  润新知