Wrapper around the reference C implementation of Argon2.
implementation 'org.signal:argon2:13.1@aar'
Argon2 argon2 = new Argon2.Builder(Version.V13)
.type(Type.Argon2id)
.memoryCost(MemoryCost.MiB(32))
.parallelism(1)
.iterations(3)
.build();
Argon2.Result result = argon2.hash(password, salt);
byte[] hash = result.getHash();
String hashHex = result.getHashHex();
String encoded = result.getEncoded();
Add the following line to your Podfile:
pod 'Argon2', git: 'https://github.com/signalapp/Argon2.git', submodules: true
let (rawHash, encodedHash) = Argon2.hash(
iterations: 1,
memoryInKiB: 32 * 1024,
threads: 1,
password: password,
salt: salt,
desiredLength: 32,
variant: .id,
version: .v13
)