?? sha1.html
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc on Tue Mar 30 01:59:35 GMT+03:00 2004 -->
<TITLE>
SHA1: Class SHA1
</TITLE>
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
</HEAD>
<BODY BGCOLOR="white">
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/SHA1.html"><FONT ID="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-tree.html"><FONT ID="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="deprecated-list.html"><FONT ID="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="index-files/index-1.html"><FONT ID="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="help-doc.html"><FONT ID="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<table>
<tr>
<td nowrap>
<b>CTXM</b> is a software house and IT services outsourcing provider.
</td>
</tr>
<tr>
<td nowrap>
<b>CTXM</b> development centers are located in Riga, Latvia and Minsk, Belarus.
</td>
</tr>
<tr>
<td nowrap>
<b>CTXM</b> is a subsidiary of Com-Tec-Co SA. from Luxembourg.
</td>
</tr>
<tr>
<td nowrap>
<b>CTXM</b> is certified by Lloyd's Register Quality Assurance as complying with ISO 9001:2001.
</td>
</tr>
</table></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
PREV CLASS
NEXT CLASS</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="index.html" TARGET="_top"><B>FRAMES</B></A>
<A HREF="SHA1.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
Class SHA1</H2>
<PRE>
java.lang.Object
|
+--<B>SHA1</B>
</PRE>
<HR>
<DL>
<DT>public abstract class <B>SHA1</B><DT>extends java.lang.Object</DL>
<P>
<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.
<P>
<HR>
<P>
<!-- ======== INNER CLASS SUMMARY ======== -->
<!-- =========== FIELD SUMMARY =========== -->
<A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Field Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private static java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="SHA1.html#b64pad">b64pad</A></B></CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="SHA1.html#chrsz">chrsz</A></B></CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private static boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="SHA1.html#hexcase">hexcase</A></B></CODE>
<BR>
</TD>
</TR>
</TABLE>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="SHA1.html#SHA1()">SHA1</A></B>()</CODE>
<BR>
</TD>
</TR>
</TABLE>
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="SHA1.html#b64_hmac_sha1(java.lang.String, java.lang.String)">b64_hmac_sha1</A></B>(java.lang.String key, java.lang.String data)</CODE>
<BR>
This is one of the functions you'll usually want to call It take a string arguments and returns either hex or base-64 encoded strings Creation date: (3/27/2004 6:05:10 PM)</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="SHA1.html#b64_sha1(java.lang.String)">b64_sha1</A></B>(java.lang.String s)</CODE>
<BR>
This is one of the functions you'll usually want to call It take a string argument and returns either hex or base-64 encoded strings Creation date: (3/27/2004 6:05:10 PM)</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private static java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="SHA1.html#binb2b64(int[])">binb2b64</A></B>(int[] binarray)</CODE>
<BR>
Convert an array of big-endian words to a base-64 string Creation date: (3/27/2004 6:05:10 PM)</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private static java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="SHA1.html#binb2hex(int[])">binb2hex</A></B>(int[] binarray)</CODE>
<BR>
Convert an array of big-endian words to a hex string.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private static java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="SHA1.html#binb2str(int[])">binb2str</A></B>(int[] bin)</CODE>
<BR>
Convert an array of big-endian words to a string Creation date: (3/27/2004 6:05:10 PM)</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="SHA1.html#bit_rol(int, int)">bit_rol</A></B>(int num, int cnt)</CODE>
<BR>
Bitwise rotate a 32-bit number to the left.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private static java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="SHA1.html#cleanB64Str(java.lang.String)">cleanB64Str</A></B>(java.lang.String str)</CODE>
<BR>
Cleans a base64 String from all the trailing 'A' or other characters put there by binb2b64 that made the bin array 4 times larger than it originally was.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private static int[]</CODE></FONT></TD>
<TD><CODE><B><A HREF="SHA1.html#complete216(int[])">complete216</A></B>(int[] oldbin)</CODE>
<BR>
Makes an int array of a length less than 16 an array of length 16 with all previous cells at their previous indexes.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private static int[]</CODE></FONT></TD>
<TD><CODE><B><A HREF="SHA1.html#concat(int[], int[])">concat</A></B>(int[] oldbin, int[] newbin)</CODE>
<BR>
Joins two int arrays and return one that contains all the previous values.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private static int[]</CODE></FONT></TD>
<TD><CODE><B><A HREF="SHA1.html#core_hmac_sha1(java.lang.String, java.lang.String)">core_hmac_sha1</A></B>(java.lang.String key, java.lang.String data)</CODE>
<BR>
Calculate the HMAC-SHA1 of a key and some data Creation date: (3/26/2004 1:05:01 PM)</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>private static int[]</CODE></FONT></TD>
<TD><CODE><B><A HREF="SHA1.html#core_sha1(int[], int)">core_sha1</A></B>(int[] x, int len)</CODE>
<BR>
Calculate the SHA-1 of an array of big-endian words, and a bit length Creation date: (3/26/2004 1:05:01 PM)</TD>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -