List of usage examples for org.bouncycastle.crypto PBEParametersGenerator init
public void init(byte[] password, byte[] salt, int iterationCount)
From source file:org.springframework.security.crypto.encrypt.BouncyCastleAesBytesEncryptor.java
License:Apache License
BouncyCastleAesBytesEncryptor(String password, CharSequence salt, BytesKeyGenerator ivGenerator) { if (ivGenerator.getKeyLength() != 16) { throw new IllegalArgumentException("ivGenerator key length != block size 16"); }/*from ww w. j av a 2 s .com*/ this.ivGenerator = ivGenerator; PBEParametersGenerator keyGenerator = new PKCS5S2ParametersGenerator(); byte[] pkcs12PasswordBytes = PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(password.toCharArray()); keyGenerator.init(pkcs12PasswordBytes, Hex.decode(salt), 1024); this.secretKey = (KeyParameter) keyGenerator.generateDerivedParameters(256); }