Skip to content

Instantly share code, notes, and snippets.

@mlsaito
Last active May 22, 2018 02:56
Show Gist options
  • 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 '[email protected]:samplePassword' | openssl base64
> bWFrb0ByaW5nY2FwdGNoYS5jb206c2FtcGxlUGFzc3dvcmQK
Decoding from Base64:
$ echo 'bWFrb0ByaW5nY2FwdGNoYS5jb206c2FtcGxlUGFzc3dvcmQK' | openssl base64 -d
> [email protected]: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 "[email protected]: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