class Mysql::Authenticator::MysqlNativePassword
mysql_native_password
Public Class Methods
Source
# File lib/mysql/authenticator/mysql_native_password.rb, line 8 def initialize(protocol) @protocol = protocol end
@param protocol [Mysql::Protocol]
Public Instance Methods
Source
# File lib/mysql/authenticator/mysql_native_password.rb, line 21 def authenticate(passwd, scramble) yield hash_password(passwd, scramble) @protocol.read end
@param passwd [String] @param scramble [String] @yield [String] hashed password @return [Mysql::Packet]
Source
# File lib/mysql/authenticator/mysql_native_password.rb, line 29 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
@param passwd [String] @param scramble [String] @return [String] hashed password
Source
# File lib/mysql/authenticator/mysql_native_password.rb, line 13 def name 'mysql_native_password' end
@return [String]