Skip to content

Instantly share code, notes, and snippets.

@mlsaito
Last active May 22, 2018 02:56
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 mlsaito/066395877ebde9491bcc08a7b5838202 to your computer and use it in GitHub Desktop.
Save mlsaito/066395877ebde9491bcc08a7b5838202 to your computer and use it in GitHub Desktop.
Convert strings to Base64 encoding in MacOS using OpenSS
Encoding to Base64:
$ echo 'mako@ringcaptcha.com:samplePassword' | openssl base64
> bWFrb0ByaW5nY2FwdGNoYS5jb206c2FtcGxlUGFzc3dvcmQK
Decoding from Base64:
$ echo 'bWFrb0ByaW5nY2FwdGNoYS5jb206c2FtcGxlUGFzc3dvcmQK' | openssl base64 -d
> mako@ringcaptcha.com:samplePassword
@mlsaito
Copy link
Author

mlsaito commented May 22, 2018

Helpful for converting account credentials to Base64 for Basic HTTP Header when making HTTP requests.

curl -H "Basic: bWFrb0ByaW5nY2FwdGNoYS5jb206c2FtcGxlUGFzc3dvcmQK" https://someApi.com/getData?id=523

Or you could simply just do:

curl --user "mako@ringcaptcha.com:samplePassword" https://someApi.com/getData?id=523

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment