class Mysql::Authenticator::MysqlNativePassword
Public Class Methods
new(protocol)
click to toggle source
@param protocol [Mysql::Protocol]
# File lib/mysql/authenticator/mysql_native_password.rb, line 7 def initialize(protocol) @protocol = protocol end
Public Instance Methods
authenticate(passwd, scramble) { |hash_password(passwd, scramble)| ... }
click to toggle source
@param passwd [String] @param scramble [String] @yield [String] hashed password @return [Mysql::Packet]
# File lib/mysql/authenticator/mysql_native_password.rb, line 20 def authenticate(passwd, scramble) yield hash_password(passwd, scramble) @protocol.read end
hash_password(passwd, scramble)
click to toggle source
@param passwd [String] @param scramble [String] @return [String] hashed password
# File lib/mysql/authenticator/mysql_native_password.rb, line 28 def hash_password(passwd, scramble) return '' if passwd.nil? or passwd.empty? hash1 = Digest::SHA1.digest(passwd) hash2 = Digest::SHA1.digest(hash1) hash3 = Digest::SHA1.digest(scramble + hash2) hash1.unpack("C*").zip(hash3.unpack("C*")).map{|a, b| a ^ b}.pack("C*") end
name()
click to toggle source
@return [String]
# File lib/mysql/authenticator/mysql_native_password.rb, line 12 def name 'mysql_native_password' end