Skip to content

Commit

Permalink
Use Integer rather than to_i
Browse files Browse the repository at this point in the history
While we know the various parameters of a hash are valid integers,
prefer to use Integer over to_i due to its defensive nature (i.e. it'll
raise an error if given invalid input vs silently returning 0).
  • Loading branch information
mudge committed Nov 1, 2024
1 parent 9528d41 commit 4c03061
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/argon2id/password.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ def initialize(encoded)

@encoded = $&
@type = $1
@version = ($2 || 0x10).to_i
@m_cost = $3.to_i
@t_cost = $4.to_i
@parallelism = $5.to_i
@version = Integer($2 || 0x10)
@m_cost = Integer($3)
@t_cost = Integer($4)
@parallelism = Integer($5)
@salt = $6.unpack1("m")
end

Expand Down

0 comments on commit 4c03061

Please sign in to comment.