lib/rbnacl/password_hash/scrypt.rb in rbnacl-3.4.0 vs lib/rbnacl/password_hash/scrypt.rb in rbnacl-4.0.0.pre
- old
+ new
@@ -1,6 +1,8 @@
# encoding: binary
+# frozen_string_literal: true
+
module RbNaCl
module PasswordHash
# The scrypt sequential memory hard password hashing function
#
# scrypt is a password hash (or password based KDF). That is to say, where
@@ -52,10 +54,12 @@
# @return [String] scrypt digest of the string as raw bytes
def digest(password, salt)
digest = Util.zeros(@digest_size)
salt = Util.check_string(salt, SALTBYTES, "salt")
- self.class.scrypt(digest, @digest_size, password, password.bytesize, salt, @opslimit, @memlimit) || raise(CryptoError, "scrypt failed!")
+ success = self.class.scrypt(digest, @digest_size, password, password.bytesize, salt, @opslimit, @memlimit)
+ raise CryptoError, "scrypt failed!" unless success
+
digest
end
end
end
end