From 4d2990eb7be9de55854a556cb36047c2a96b2eca Mon Sep 17 00:00:00 2001 From: Josh Buker Date: Sat, 10 Apr 2021 10:49:38 -0700 Subject: [PATCH] Update documentation with details from PHC string format definition --- lib/argon2/password.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/argon2/password.rb b/lib/argon2/password.rb index d33db33..eebe51c 100644 --- a/lib/argon2/password.rb +++ b/lib/argon2/password.rb @@ -27,10 +27,25 @@ class Password # Used to validate the maximum acceptable parallelism cost MAX_P_COST = 8 # The complete Argon2 digest string (not to be confused with the checksum). + # + # For a detailed description of the digest format, please see: + # https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md attr_reader :digest - # The hash portion of the stored password hash. + # The hash portion of the stored password hash. This is Base64 encoded by + # default. attr_reader :checksum - # The salt of the stored password hash. + # The salt of the stored password hash. This is Base64 encoded by default. + # + # To retrieve the original salt: + # + # require 'base64' + # + # argon2 = Argon2::Password.new(digest) + # + # argon2.salt + # => Base64 encoded salt + # Base64.decode64(argon2.salt) + # => original salt attr_reader :salt # Variant used (argon2i / argon2d / argon2id) attr_reader :variant