Skip to content

Commit e7440a9

Browse files
committed
hash in ruby
1 parent 9bb6e3f commit e7440a9

File tree

1 file changed

+2
-1
lines changed
  • app/webapp/ruby/lib/torb

1 file changed

+2
-1
lines changed

app/webapp/ruby/lib/torb/web.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require 'erubi'
44
require 'mysql2'
55
require 'mysql2-cs-bind'
6+
require 'openssl'
67

78
module Torb
89
class Web < Sinatra::Base
@@ -272,7 +273,7 @@ def render_report_csv(reports)
272273
password = body_params['password']
273274

274275
user = db.xquery('SELECT * FROM users WHERE login_name = ?', login_name).first
275-
pass_hash = db.xquery('SELECT SHA2(?, 256) AS pass_hash', password).first['pass_hash']
276+
pass_hash = OpenSSL::Digest::SHA256.hexdigest(password)
276277
halt_with_error 401, 'authentication_failed' if user.nil? || pass_hash != user['pass_hash']
277278

278279
session['user_id'] = user['id']

0 commit comments

Comments
 (0)