Skip to content

Commit 34b1915

Browse files
committed
Fixes #4.
1 parent 807f86f commit 34b1915

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/argon2/ffi_engine.rb

+6-4
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def self.hash_argon2i(password, salt, t_cost, m_cost)
4747

4848
def self.hash_argon2i_encode(password, salt, t_cost, m_cost, secret)
4949
result = ''
50-
secretlen = secret.nil? ? 0 : secret.length
51-
passwordlen = password.nil? ? 0 : password.length
50+
secretlen = secret.nil? ? 0 : secret.bytesize
51+
passwordlen = password.nil? ? 0 : password.bytesize
5252
if salt.length != Constants::SALT_LEN
5353
raise ArgonHashFail, "Invalid salt size"
5454
end
@@ -63,8 +63,10 @@ def self.hash_argon2i_encode(password, salt, t_cost, m_cost, secret)
6363
end
6464

6565
def self.argon2i_verify(pwd, hash, secret)
66-
secretlen = secret.nil? ? 0 : secret.length
67-
ret = Ext.wrap_argon2_verify(hash, pwd, pwd.length, secret, secretlen)
66+
secretlen = secret.nil? ? 0 : secret.bytesize
67+
passwordlen = pwd.nil? ? 0 : pwd.bytesize
68+
69+
ret = Ext.wrap_argon2_verify(hash, pwd, passwordlen, secret, secretlen)
6870
return false if ERRORS[ret] == 'ARGON2_DECODING_FAIL'
6971
raise ArgonHashFail, ERRORS[ret] unless ret == 0
7072
true

0 commit comments

Comments
 (0)