5
votes

Really confused - Guess it has to do with a single character placement at the end, or possible padding done with basic digest that I'm not aware of..?

So, if I execute this, you can see the product of the base64 encode:

echo '[email protected]:password' | openssl enc -base64
aG9zdEBtYWlsLmNvbTpwYXNzd29yZAo=

Now, if I make a curl request:

curl -v -u [email protected]:password https://
aG9zdEBtYWlsLmNvbTpwYXNzd29yZA==

You'll notice that the base64 strings are NOT the same..haha what? The base64 command line one is actually incorrect - if you substitute that in the request, it fails. SO - does basic digest NOT truly use a base64 string? I'm noticing that is always doing a o= instead of == at the end of the string ...

And ideas?

EDIT: So, it was the trailing newline from echo: -n do not output the trailing newline

Thanks!

1

1 Answers

8
votes
>>> 'aG9zdEBtYWlsLmNvbTpwYXNzd29yZA=='.decode('base64')
'[email protected]:password'
>>> 'aG9zdEBtYWlsLmNvbTpwYXNzd29yZAo='.decode('base64')
'[email protected]:password\n'

Try echo -n instead.