List of usage examples for org.apache.shiro.codec Hex encodeToString
public static String encodeToString(byte[] bytes)
From source file:cn.com.rexen.ext.shiro.web.filter.authc.ForwardedX509AuthenticationFilter.java
License:Open Source License
private String readHexSerialNumberFromString(String input) { return Hex.encodeToString(Hex.decode(input)); // FIXME Upstream Hex implementation is not char encoding safe, fix it there }
From source file:com.ncr.itss.core.utils.StringUtils.java
License:Open Source License
/** * md5/*from w ww .java2 s .com*/ * * @param str . * @return . */ public static String md5AsBase64(String str) { String base64Encoded = Hex.encodeToString(str.getBytes()); return base64Encoded; }
From source file:com.once.crosscloud.utils.EndecryptUtils.java
License:Apache License
/** * 16 //from ww w . j av a 2 s .c o m * * @param password * @return */ public static String encrytHex(String password) { byte[] bytes = password.getBytes(); return Hex.encodeToString(bytes); }
From source file:com.rencw.framework.shiro.SimpleByteSource.java
License:Apache License
public String toHex() { if (this.cachedHex == null) { this.cachedHex = Hex.encodeToString(getBytes()); }//w w w .ja va 2s. c o m return this.cachedHex; }
From source file:com.zht.common.shiro.util.EndecryptUtils.java
License:Apache License
/** * 16 /* w w w. ja v a 2 s .co m*/ * @param password * @return */ public static String encrytHex(String password) { if (password == null) { return null; } byte[] bytes = password.getBytes(); return Hex.encodeToString(bytes); }
From source file:de.dominikschadow.javasecurity.hash.SHA512.java
License:Apache License
private static boolean verifyPassword(byte[] originalHash, ByteSource publicSalt, String password) { ByteSource privateSalt = ByteSource.Util.bytes(PRIVATE_SALT_BYTES); DefaultHashService hashService = new DefaultHashService(); hashService.setPrivateSalt(privateSalt); hashService.setHashIterations(ITERATIONS); HashRequest.Builder builder = new HashRequest.Builder(); builder.setSource(ByteSource.Util.bytes(password)); builder.setSalt(publicSalt);// w ww. ja v a 2 s. com Hash comparisonHash = hashService.computeHash(builder.build()); log.info("password: {}", password); log.info("1 hash: {}", Hex.encodeToString(originalHash)); log.info("2 hash: {}", comparisonHash.toHex()); return Arrays.equals(originalHash, comparisonHash.getBytes()); }
From source file:de.dominikschadow.javasecurity.symmetric.AES.java
License:Apache License
private static void printReadableMessages(String initialText, byte[] ciphertext, byte[] plaintext) { log.info("initialText: {}", initialText); log.info("cipherText as byte[]: {}", new String(ciphertext)); log.info("cipherText as HEX: {}", Hex.encodeToString(ciphertext)); log.info("plaintext: {}", CodecSupport.toString(plaintext)); }
From source file:org.graylog2.security.AESTools.java
License:Open Source License
public static String encrypt(String plainText, String encryptionKey, String salt) { try {//w w w . jav a 2s.c o m Cipher cipher = Cipher.getInstance("AES/CBC/ISO10126Padding", "SunJCE"); SecretKeySpec key = new SecretKeySpec(encryptionKey.getBytes("UTF-8"), "AES"); cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(salt.getBytes("UTF-8"))); return Hex.encodeToString(cipher.doFinal(plainText.getBytes("UTF-8"))); } catch (Exception e) { LOG.error("Could not encrypt value.", e); } return null; }
From source file:org.graylog2.security.ldap.LdapSettingsImpl.java
License:Open Source License
@Override public void setSystemPassword(String systemPassword) { // set new salt value, if we didn't have any. if (getSystemPasswordSalt().isEmpty()) { LOG.debug("Generating new salt for LDAP system password."); final SecureRandom random = new SecureRandom(); byte[] saltBytes = new byte[8]; random.nextBytes(saltBytes);/* w ww. j a va2 s . c om*/ setSystemPasswordSalt(Hex.encodeToString(saltBytes)); } final String encrypted = AESTools.encrypt(systemPassword, configuration.getPasswordSecret().substring(0, 16), getSystemPasswordSalt()); fields.put(SYSTEM_PASSWORD, encrypted); }
From source file:org.obiba.mica.micaConfig.service.MicaConfigService.java
License:Open Source License
private String generateSecretKey() { Key key = cipherService.generateNewKey(); return Hex.encodeToString(key.getEncoded()); }