lib/blind_index.rb in blind_index-2.5.0 vs lib/blind_index.rb in blind_index-2.6.0
- old
+ new
@@ -49,11 +49,11 @@
# https://gist.github.com/ankane/fe3ac63fbf1c4550ee12554c664d2b8c
cost_options = options[:cost] || {}
# check size
size = (options[:size] || 32).to_i
- raise BlindIndex::Error, "Size must be between 1 and 32" unless (1..32).include?(size)
+ raise BlindIndex::Error, "Size must be between 1 and 32" unless (1..32).cover?(size)
value = value.to_s
value =
case algorithm
@@ -68,11 +68,11 @@
raise BlindIndex::Error, "m must be between 3 and 22" if m < 3 || m > 22
Argon2::KDF.argon2id(value, salt: key, t: t, m: m, p: 1, length: size)
when :pbkdf2_sha256
iterations = cost_options[:iterations] || options[:iterations] || (options[:slow] ? 100000 : 10000)
- OpenSSL::PKCS5.pbkdf2_hmac(value, key, iterations, size, "sha256")
+ OpenSSL::KDF.pbkdf2_hmac(value, salt: key, iterations: iterations, length: size, hash: "sha256")
when :argon2i
t = (cost_options[:t] || 3).to_i
# use same bounds as rbnacl
raise BlindIndex::Error, "t must be between 3 and 10" if t < 3 || t > 10
@@ -84,10 +84,10 @@
Argon2::KDF.argon2i(value, salt: key, t: t, m: m, p: 1, length: size)
when :scrypt
n = cost_options[:n] || 4096
r = cost_options[:r] || 8
cp = cost_options[:p] || 1
- SCrypt::Engine.scrypt(value, key, n, r, cp, size)
+ OpenSSL::KDF.scrypt(value, salt: key, N: n, r: r, p: cp, length: size)
else
raise BlindIndex::Error, "Unknown algorithm"
end
encode = options[:encode]