Register
It is currently Wed Apr 23, 2014 8:43 pm

convert string to md5 [solved]


All times are UTC - 6 hours


Post new topic Reply to topic  [ 8 posts ] 
Author Message
 PostPosted: Mon Nov 08, 2010 10:46 am   

Joined: Mon Nov 08, 2010 10:39 am
Posts: 17
Hello everyone,

I'm curious if it's possible to convert a string to md5 using bash itself. I was looking for this info in the internet as well as in the forums but without result. I need to have a little script which will generate a password and its md5 hash. I would be grateful for any directions to find the solution.

Thank you in advance.


Last edited by lush on Wed Nov 10, 2010 5:07 am, edited 1 time in total.

Top
 Profile  
 PostPosted: Mon Nov 08, 2010 2:59 pm   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
It might be possible to program the whole algorithm in bash, yet it is far more convenient to just use
Code:
echo -n password | md5sum


Top
 Profile  
 PostPosted: Tue Nov 09, 2010 3:51 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 224
Location: London - UK
choroba wrote:
It might be possible to program the whole algorithm in bash


bash is Turing complete so it can do anything a computer can do.
http://en.wikipedia.org/wiki/Turing_completeness


Top
 Profile  
 PostPosted: Tue Nov 09, 2010 4:04 am   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
DarthWavy wrote:
bash is Turing complete so it can do anything a computer can do.

Well, yeah, I know, but I am not Turing complete to write it o:|


Top
 Profile  
 PostPosted: Tue Nov 09, 2010 8:15 am   

Joined: Mon Nov 08, 2010 10:39 am
Posts: 17
Quote:
Well, yeah, I know, but I am not Turing complete to write it


So, am I))

Anyway, I tried the following:
Code:
echo "D&Y%YGBm" | md5sum


and get the result:
Code:
e180ac1293640daf137fb5012d62a503  -


Sorry, for this question but are space and the hyphen parts of the md5 code? I have been trying to reset wordpress password (with I used e180ac1293640daf137fb5012d62a503) via phpMyAdmin tool using this md5 code and I failed. Looks like I am doing something wrong.


Top
 Profile  
 PostPosted: Tue Nov 09, 2010 11:39 pm   
User avatar

Joined: Sun Jun 27, 2010 12:57 am
Posts: 192
You used 'echo' and not 'echo -n'. This means the newline at the end of your password is also encoded in the md5sum and so part of your password. Please use 'echo -n'. Also you don't need the space and hyphen behind the md5 itself, it's not part of the md5, that is the 'filename' md5sum used as input (and the hyphen means it used stdin)


Top
 Profile  
 PostPosted: Wed Nov 10, 2010 5:00 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 224
Location: London - UK
what it seems you're after is;

Code:
echo -n "mystring" | md5sum | awk '{ print $1 }'


The echo -n thing always catches people out the first time they use md5 heh


Top
 Profile  
 PostPosted: Wed Nov 10, 2010 5:06 am   

Joined: Mon Nov 08, 2010 10:39 am
Posts: 17
Thank you so much! All of you!


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP