public String encode(String password, byte[] salt, int rounds) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeySpecException { PKCS5S2ParametersGenerator generator = new PKCS5S2ParametersGenerator(); generator.init(PBEParametersGenerator.PKCS5PasswordToBytes( password.toCharArray()), salt, rounds); return format("%s:%s:%d", encode(salt), encode(((KeyParameter)generator.generateDerivedParameters(s_keylen)).getKey()), rounds); }
/** {@inheritDoc} */ protected byte[] toBytes(final char[] password) { return PBEParametersGenerator.PKCS5PasswordToBytes(password); } }
public byte[] convert(char[] password) { return PBEParametersGenerator.PKCS5PasswordToBytes(password); } },
/** {@inheritDoc} */ protected byte[] toBytes(final char[] password) { return PBEParametersGenerator.PKCS5PasswordToBytes(password); } }
/** * Converts a password to a byte array according to the scheme in PKCS5 (ascii, no padding) * * @param password a character array representing the password. * @return a byte array representing the password. */ public static byte[] PKCS5PasswordToBytes(char[] password) { return PBEParametersGenerator.PKCS5PasswordToBytes(password); }
return PKCS5PasswordToBytes(characters);
return PKCS5PasswordToBytes(characters);
/** {@inheritDoc} */ public byte[] generate(final char[] password, final int size) { final OpenSSLPBEParametersGenerator generator = new OpenSSLPBEParametersGenerator(); generator.init(PBEParametersGenerator.PKCS5PasswordToBytes(password), salt); final KeyParameter p = (KeyParameter) generator.generateDerivedParameters( size); return p.getKey(); } }
private static byte[] convertPassword(int type, PBEKeySpec keySpec) { byte[] key; if (type == PKCS12) { key = PBEParametersGenerator.PKCS12PasswordToBytes(keySpec.getPassword()); } else if (type == PKCS5S2_UTF8 || type == PKCS5S1_UTF8) { key = PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(keySpec.getPassword()); } else { key = PBEParametersGenerator.PKCS5PasswordToBytes(keySpec.getPassword()); } return key; } }
return PBEParametersGenerator.PKCS5PasswordToBytes(pbeKeySpec.getPassword());