AES加密工具类

时间:2021-12-20 09:07:48
【文件属性】:

文件名称:AES加密工具类

文件大小:4KB

文件格式:JAVA

更新时间:2021-12-20 09:07:48

java

可用于登陆时对密码进行加密public static byte[] encrypt(String cleartext, String dataPassword) { Date startDate = new Date(); logger.info("encrypt begin : " + startDate); byte[] encryptedData = null; try { IvParameterSpec zeroIv = new IvParameterSpec(VIPARA.getBytes()); SecretKeySpec key = new SecretKeySpec(dataPassword.getBytes(), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, key, zeroIv); encryptedData = cipher.doFinal(cleartext.getBytes(bm)); } catch (Exception e) { logger.error("encrypt error :", e); } logger.info("encrypt run end(s) : " + DateUtil.calLastedTime(startDate)); return encryptedData; }


网友评论