LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-16-2011, 11:00 AM   #1
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,027

Rep: Reputation: 69
A question about generating base64 strings...


I've been messing around with smtp auth plain authentication. I've been using the following command to generate the auth plain base64 hash.
Code:
perl -MMIME::Base64 -e 'print encode_base64("\000username\@domain.com\000password")'
And that hash has been working great. However, I wanted to use something a little easier to remember. So I tried the following.
Code:
echo -n "\000username\@domain.com\000password" | base64
but the resulting hash is different. I can't seem to figure it out. What do the '\000' represent?
 
Old 03-16-2011, 11:26 AM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Arch
Posts: 3,013

Rep: Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225
Quote:
What do the '\000' represent?
They represent 0 (or NUL) bytes, which are distinct from bytes representing the character "0" (that would be 48 or 0x30). You have to pass the -e option to echo so interprets the escape sequence.

Quote:
auth plain base64 hash
Just to be clear, base64 encoding isn't a hash.
 
Old 03-16-2011, 02:21 PM   #3
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,027

Original Poster
Rep: Reputation: 69
Ah got it. I needed to just have the nulls in quotes. So this worked.
Code:
echo -ne "\000"username\@domain.com"\000"password | base64
You need the '-n' so that newlines will not be printed. You need the '-e' so that the escapes will be accounted for.
Thanks ntubski for pointing me in the right direction.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] A innocent question about generating CSV file with php koshihaku Linux - Server 2 08-24-2010 09:47 PM
Using ; in command strings question. Thaidog Linux - General 2 04-21-2007 08:01 PM
Statistics and Programming Question, generating a random number firefly2442 Programming 2 01-06-2006 05:33 PM
strings question sibtay Programming 7 10-01-2004 11:37 AM
Help with a script (question on strings) wswartz Linux - General 3 07-11-2004 09:53 AM


All times are GMT -5. The time now is 12:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration