@Override public void init(Map<String, String> params) throws Exception { String algorithm = params.get(ALGORITHM); if (algorithm == null || algorithm.equals(TWO_WAY)) { //two way this.algorithm = new BlowfishAlgorithm(params); } else if (algorithm.equals(ONE_WAY)) { this.algorithm = new PBKDF2Algorithm(params); } else { throw new IllegalArgumentException("Invalid algorithm: " + algorithm); } }
@Override public String encode(String secret) throws Exception { char[] chars = secret.toCharArray(); byte[] salt = getSalt(); StringBuilder builder = new StringBuilder(); builder.append(iterations).append(SEPARATOR).append(ByteUtil.bytesToHex(salt)).append(SEPARATOR); PBEKeySpec spec = new PBEKeySpec(chars, salt, iterations, keyLength); byte[] hash = skf.generateSecret(spec).getEncoded(); String hexValue = ByteUtil.bytesToHex(hash); builder.append(hexValue); return builder.toString(); }
@Override public void init(Map<String, String> params) throws Exception { String algorithm = params.get(ALGORITHM); if (algorithm == null || algorithm.equals(TWO_WAY)) { //two way this.algorithm = new BlowfishAlgorithm(params); } else if (algorithm.equals(ONE_WAY)) { this.algorithm = new PBKDF2Algorithm(params); } else { throw new IllegalArgumentException("Invalid algorithm: " + algorithm); } }
@Override public void init(Map<String, String> params) throws Exception { String algorithm = params.get(ALGORITHM); if (algorithm == null || algorithm.equals(TWO_WAY)) { //two way this.algorithm = new BlowfishAlgorithm(params); } else if (algorithm.equals(ONE_WAY)) { this.algorithm = new PBKDF2Algorithm(params); } else { throw new IllegalArgumentException("Invalid algorithm: " + algorithm); } }
@Override public String encode(String secret) throws Exception { char[] chars = secret.toCharArray(); byte[] salt = getSalt(); StringBuilder builder = new StringBuilder(); builder.append(iterations).append(SEPARATOR).append(ByteUtil.bytesToHex(salt)).append(SEPARATOR); PBEKeySpec spec = new PBEKeySpec(chars, salt, iterations, keyLength); byte[] hash = skf.generateSecret(spec).getEncoded(); String hexValue = ByteUtil.bytesToHex(hash); builder.append(hexValue); return builder.toString(); }
@Override public String encode(String secret) throws Exception { char[] chars = secret.toCharArray(); byte[] salt = getSalt(); StringBuilder builder = new StringBuilder(); builder.append(iterations).append(SEPARATOR).append(ByteUtil.bytesToHex(salt)).append(SEPARATOR); PBEKeySpec spec = new PBEKeySpec(chars, salt, iterations, keyLength); byte[] hash = skf.generateSecret(spec).getEncoded(); String hexValue = ByteUtil.bytesToHex(hash); builder.append(hexValue); return builder.toString(); }
@Override public void init(Map<String, String> params) throws Exception { String algorithm = params.get(ALGORITHM); if (algorithm == null || algorithm.equals(TWO_WAY)) { //two way this.algorithm = new BlowfishAlgorithm(params); } else if (algorithm.equals(ONE_WAY)) { this.algorithm = new PBKDF2Algorithm(params); } else { throw new IllegalArgumentException("Invalid algorithm: " + algorithm); } }
@Override public String encode(String secret) throws Exception { char[] chars = secret.toCharArray(); byte[] salt = getSalt(); StringBuilder builder = new StringBuilder(); builder.append(iterations).append(SEPARATOR).append(ByteUtil.bytesToHex(salt)).append(SEPARATOR); PBEKeySpec spec = new PBEKeySpec(chars, salt, iterations, keyLength); byte[] hash = skf.generateSecret(spec).getEncoded(); String hexValue = ByteUtil.bytesToHex(hash); builder.append(hexValue); return builder.toString(); }
@Override public void init(Map<String, String> params) throws Exception { String algorithm = params.get(ALGORITHM); if (algorithm == null || algorithm.equals(TWO_WAY)) { //two way this.algorithm = new BlowfishAlgorithm(params); } else if (algorithm.equals(ONE_WAY)) { this.algorithm = new PBKDF2Algorithm(params); } else { throw new IllegalArgumentException("Invalid algorithm: " + algorithm); } }
@Override public String encode(String secret) throws Exception { char[] chars = secret.toCharArray(); byte[] salt = getSalt(); StringBuilder builder = new StringBuilder(); builder.append(iterations).append(SEPARATOR).append(ByteUtil.bytesToHex(salt)).append(SEPARATOR); PBEKeySpec spec = new PBEKeySpec(chars, salt, iterations, keyLength); byte[] hash = skf.generateSecret(spec).getEncoded(); String hexValue = ByteUtil.bytesToHex(hash); builder.append(hexValue); return builder.toString(); }
@Override public String encode(String secret) throws Exception { char[] chars = secret.toCharArray(); byte[] salt = getSalt(); StringBuilder builder = new StringBuilder(); builder.append(iterations).append(SEPARATOR).append(ByteUtil.bytesToHex(salt)).append(SEPARATOR); PBEKeySpec spec = new PBEKeySpec(chars, salt, iterations, keyLength); byte[] hash = skf.generateSecret(spec).getEncoded(); String hexValue = ByteUtil.bytesToHex(hash); builder.append(hexValue); return builder.toString(); }
@Override public String encode(String secret) throws Exception { char[] chars = secret.toCharArray(); byte[] salt = getSalt(); StringBuilder builder = new StringBuilder(); builder.append(iterations).append(SEPARATOR).append(ByteUtil.bytesToHex(salt)).append(SEPARATOR); PBEKeySpec spec = new PBEKeySpec(chars, salt, iterations, keyLength); byte[] hash = skf.generateSecret(spec).getEncoded(); String hexValue = ByteUtil.bytesToHex(hash); builder.append(hexValue); return builder.toString(); }
@Override public void init(Map<String, String> params) throws Exception { String algorithm = params.get(ALGORITHM); if (algorithm == null || algorithm.equals(TWO_WAY)) { //two way this.algorithm = new BlowfishAlgorithm(params); } else if (algorithm.equals(ONE_WAY)) { this.algorithm = new PBKDF2Algorithm(params); } else { throw new IllegalArgumentException("Invalid algorithm: " + algorithm); } }
@Override public void init(Map<String, String> params) throws Exception { String algorithm = params.get(ALGORITHM); if (algorithm == null || algorithm.equals(TWO_WAY)) { //two way this.algorithm = new BlowfishAlgorithm(params); } else if (algorithm.equals(ONE_WAY)) { this.algorithm = new PBKDF2Algorithm(params); } else { throw new IllegalArgumentException("Invalid algorithm: " + algorithm); } }