WEB开发网
开发学院WEB开发Jsp java版的SHA-1 阅读

java版的SHA-1

 2008-01-05 09:10:27 来源:WEB开发网   
核心提示:/** * <b>This java Class consists the server side for the wondeful javascript library 'sha1.js'. I wrote it because I basically needed * some

  /**
* <b>This java Class consists the server side for the wondeful javascript library 'sha1.js'. I wrote it because I basically needed
* some cheap client/server login authentication by the usual key/data system. Besides, I got the creeps watching the passWord
* posted unencrypted via http requests. This class makes sure that if your client is using the 'sha1.js' to encrypt the password
* with a key sent by the server, you can always repeat the encrypting on the server side (using the same key) and compare the
* encrypted strings. Since anyone who is trapping the http requests can actually send you the same encrypted string, I suggest
* you use the client's IP address as the base for the key generation. Since IP address spoofing is not a PRoblem, this authentication
* method is not a very secured solution. If you need a full proof solution use ssl. However, this one, sure beats nothing.
* Feel free to do with it whatever you want</b>
* <p><b>This Class is an Abstract Class, to make sure you do not create any new instances of it. It does not throw any exceptions and
* the code is mUCh more 'C' like than pure object oriented. There are no implemented interfaces and no inheritance in use. In fact, it
* is written as close as possible to the original javascript code. I did not test tweaking the instance variables but if you do change
* them, make sure to apply the same change in the 'sha1.js' library or you won't get the same encrypted strings.
* You can call each one of the 6 work methods by using something like: SHA1.hex_hmac_sha1("key", "data");
* They are the only public methods. All are public and static. You have no reason to call the private ones anyway.</p></b>
* <p>The 'sha1.js' is a javascript implementation of the Secure Hash Algorithm, SHA-1, as defined in FIPS PUB 180-1.
* javascript Version 2.1 Copyright Paul Johnston 2000 - 2002. Other contributors to javascript version: Greg Holt,
* Andrew Kepert, Ydnar, Lostinet Distributed under the BSD License</p>
* <p>See <a href="http://pajhome.org.uk/crypt/md5">http://pajhome.org.uk/crypt/md5</a> for details.</p>
* <p><b>Author: </b>T.N.Silverman (C.T.Xm - SiA Riga, LV) <a href="mailto:tnsilver@ctcm.com">mailto:tnsilver@ctxm.com</a>
* <br>Creation date: (3/27/2004 5:57:00 PM)</p>
* <p>Don't forget to visit my company, <b>CTXM</b> site at <a href="http://www.ctxm.com">http://www.ctxm.com</a> where you will find reference to all of the games this code is used in.

Tags:java SHA

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接