public
Last active

  • Download Gist
basic_auth.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12
require 'base64'
module BasicAuth
def self.encode(username, password)
s = [username, password].join(":")
"Basic #{Base64.strict_encode64 s}"
end
 
def self.decode(header)
base64 = header[/Basic (.*)/, 1]
Base64.decode64 base64.split(":")
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.