0

I need to hash a password in java script.i google it for days and find some articles but i could not understand the point. can any one help me up on this please??

2
  • Search for a SHA256 implementation for Javascript, and call the SHA256() function on your password. Commented Nov 24, 2011 at 7:55
  • 1
    Do you really need hashing? Wouldn't you be better of by encrypting your connection with SSL/https? Commented Nov 24, 2011 at 8:05

3 Answers 3

1

Javascript doesn't have a native function to hash strings.

http://pajhome.org.uk/crypt/md5/md5.html is a function someone has written to produce an md5.

Copy the code from here http://pajhome.org.uk/crypt/md5/md5.html into your javascript, then run hex_md5(s) where s is the text you want hashed.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use remakes of PHP's md5() and sha1() functions in javascript.

Comments

0

In my opinion, the safest way to do this is to send the password using ajax to a php or aspx-script and hashing it there. People will always, always be able to read your js-code, hence, they can crack the hashing algorithm, or simply mimic it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.