Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

When i take a hash of user input test123+ i get the following base64 result:- YaddchSU52yztwIMdtHzkg3p1oA= The results have been obtained using the online sha1 convertor

I m failing to understand how does this work? When i take just convert test123+ using sha1 i get d478f2a272d7830987e8cd1c732af606. Now when i do the base64 encoding on this input i get this result ZDQ3OGYyYTI3MmQ3ODMwOTg3ZThjZDFjNzMyYWY2MDY=

Why are two base64 conversion so different?

share|improve this question

1 Answer 1

up vote 10 down vote accepted

You've generating the base64 encoding of the ASCII hex string, rather than the raw bytes of the hash function's output.

share|improve this answer
    
So what you are saying the link i included above is using raw bytes to convert it into base64? –  Saladin Oct 22 '12 at 16:31
    
Yes, that's the case. –  Polynomial Oct 22 '12 at 16:32
    
But when i want to go back and retrieve the original string using hex decoding i don't get test123+ instead i get some garbage? I'm using 61a75d721494e76cb3b7020c76d1f3920de9d680 is this because it is using raw byes? right –  Saladin Oct 22 '12 at 17:00
    
Yep. The "garbage" you see is the ASCII representation of the raw bytes produced by the hash. –  Polynomial Oct 22 '12 at 17:05
    
So, this method is pretty much safe ; and beats hash recovery. –  Saladin Oct 22 '12 at 17:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.