首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Net::IMAP::CramMD5Authenticator

Parent:Object

“CRAM-MD5”为身份验证类型的身份验证器。请参阅authenticate()。

公共类方法

new(user, password) Show source

代码语言:javascript
复制
# File lib/net/imap.rb, line 3472
def initialize(user, password)
  @user = user
  @password = password
end

公共实例方法

process(challenge) Show source

代码语言:javascript
复制
# File lib/net/imap.rb, line 3465
def process(challenge)
  digest = hmac_md5(challenge, @password)
  return @user + " " + digest
end

私有实例方法

hmac_md5(text, key) Show source

代码语言:javascript
复制
# File lib/net/imap.rb, line 3477
def hmac_md5(text, key)
  if key.length > 64
    key = Digest::MD5.digest(key)
  end

  k_ipad = key + "\0" * (64 - key.length)
  k_opad = key + "\0" * (64 - key.length)
  for i in 0..63
    k_ipad[i] = (k_ipad[i].ord ^ 0x36).chr
    k_opad[i] = (k_opad[i].ord ^ 0x5c).chr
  end

  digest = Digest::MD5.digest(k_ipad + text)

  return Digest::MD5.hexdigest(k_opad + digest)
end

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com