views:

188

answers:

1

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!

+3  A: 
>>> 'aG9zdEBtYWlsLmNvbTpwYXNzd29yZA=='.decode('base64')
'[email protected]:password'
>>> 'aG9zdEBtYWlsLmNvbTpwYXNzd29yZAo='.decode('base64')
'[email protected]:password\n'

Try echo -n instead.

Ignacio Vazquez-Abrams
echo -n "[email protected]:password" | openssl enc -base64aG9zdEBtYWlsLmNvbTpwYXNzd29yZA==...Doesn't seem to work.
Mr-sk
>>> 'aG9zdEBtYWlsLmNvbTpwYXNzd29yZA=='.decode('base64') \ '[email protected]:password' ... Looks fine to me...
Ignacio Vazquez-Abrams
DOH - sorry - was comparing it against the actualy user:pass. heh, works great, thanks!
Mr-sk