Skip to content

Instantly share code, notes, and snippets.

@ConradIrwin
Last active December 10, 2015 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ConradIrwin/4463940 to your computer and use it in GitHub Desktop.
Save ConradIrwin/4463940 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment