Search in sources :

Example 1 with Argon2Parameters

use of org.bouncycastle.crypto.params.Argon2Parameters in project spring-security by spring-projects.

the class Argon2PasswordEncoder method encode.

@Override
public String encode(CharSequence rawPassword) {
    byte[] salt = this.saltGenerator.generateKey();
    byte[] hash = new byte[this.hashLength];
    // @formatter:off
    Argon2Parameters params = new Argon2Parameters.Builder(Argon2Parameters.ARGON2_id).withSalt(salt).withParallelism(this.parallelism).withMemoryAsKB(this.memory).withIterations(this.iterations).build();
    // @formatter:on
    Argon2BytesGenerator generator = new Argon2BytesGenerator();
    generator.init(params);
    generator.generateBytes(rawPassword.toString().toCharArray(), hash);
    return Argon2EncodingUtils.encode(hash, params);
}
Also used : Argon2Parameters(org.bouncycastle.crypto.params.Argon2Parameters) Argon2BytesGenerator(org.bouncycastle.crypto.generators.Argon2BytesGenerator)

Aggregations

Argon2BytesGenerator (org.bouncycastle.crypto.generators.Argon2BytesGenerator)1 Argon2Parameters (org.bouncycastle.crypto.params.Argon2Parameters)1