List of usage examples for org.apache.shiro.codec H64 encodeToString
public static String encodeToString(byte[] bytes)
From source file:com.once.crosscloud.utils.EndecryptUtils.java
License:Apache License
public static void main(String[] args) { String password = "admin"; String cipherText = encrytHex(password); System.out.println(password + "hex?" + cipherText); String decrptPassword = decryptHex(cipherText); System.out.println(cipherText + "hex??" + decrptPassword); String cipherText_base64 = encrytBase64(password); System.out.println(password + "base64?" + cipherText_base64); String decrptPassword_base64 = decryptBase64(cipherText_base64); System.out.println(cipherText_base64 + "base64??" + decrptPassword_base64); String h64 = H64.encodeToString(password.getBytes()); System.out.println(h64);//w ww . j av a 2 s . c o m String salt = "7road"; String cipherText_md5 = new Md5Hash(password, salt, 4).toHex(); System.out.println(password + "md5?" + cipherText_md5); System.out.println(generateKey()); System.out.println("=========================================================="); AesCipherService aesCipherService = new AesCipherService(); aesCipherService.setKeySize(128); Key key = aesCipherService.generateNewKey(); String aes_cipherText = aesCipherService.encrypt(password.getBytes(), key.getEncoded()).toHex(); System.out.println(password + " aes" + aes_cipherText); String aes_mingwen = new String( aesCipherService.decrypt(Hex.decode(aes_cipherText), key.getEncoded()).getBytes()); System.out.println(aes_cipherText + " aes" + aes_mingwen); }