Information Security Stack Exchange is a question and answer site for information security professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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


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.