📄 digesttool.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><TITLE>DigestTool (Project JXTA J2SE)</TITLE><META NAME="keywords" CONTENT="net.jxta.impl.id.binaryID.DigestTool class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){ parent.document.title="DigestTool (Project JXTA J2SE)";}</SCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/DigestTool.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><a href='http://www.jxta.org' target='_blank'>Project JXTA</a></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../net/jxta/impl/id/binaryID/CodatBinaryID.html" title="class in net.jxta.impl.id.binaryID"><B>PREV CLASS</B></A> <A HREF="../../../../../net/jxta/impl/id/binaryID/IDFormat.html" title="class in net.jxta.impl.id.binaryID"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../index.html" target="_top"><B>FRAMES</B></A> <A HREF="DigestTool.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | <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><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">net.jxta.impl.id.binaryID</FONT><BR>Class DigestTool</H2><PRE>java.lang.Object <IMG SRC="../../../../../resources/inherit.gif" ALT="extended by"><B>net.jxta.impl.id.binaryID.DigestTool</B></PRE><HR><DL><DT>public class <B>DigestTool</B><DT>extends java.lang.Object</DL><P>This is a utility class used to create pipe advertisement named and BinaryID for the pipeID to create a private address space that can be hosted in the public discovery system or sent over unencrypted channeds without revealing their intent or purpose. <p> We use a one-way hashing algorythum to create an ID from private information like a user's social security number or a user's email address. We search for the pipe by with this private information securly by creating the matching hash using the same methods. <p> The purpose of this system is to create a way to search for a pipe (or other BinaryID based system) without exposing the pipe owner's clearTextID while allowing for people that know what they are looking for to find the right pipe. The system also has the ability to create pipes that have a specific purpose. For example, the email address is appended with a function name. Say you have a pipe for messages and one for administrative purposes. You would supply the email and a string for the function. The same combination can be created by another peer to search for either of these pipes. <p> This implementation uses the "SHA-1" algorythum. This was selected for relitive speed. It is used as a one-way conversion that cannot be reversed engineered to create the original string. This allows you to publish the hash without the possibility of the contents being decoded. This allows for public indexing of data that is only known by the parties involved.<p> Note that this can also be used to generate safe password verification hash codes.Sample useage:<code> String clearTextID = "turbogeek@cluck.com"; String function = "eventPipe"; System.out.println("clear text ID: "+clearTextID); System.out.println("function text: "+function); String digest1 = DigestID.generateHashString(clearTextID, function); String digest2 = DigestID.generateHashString(clearTextID); System.out.println("Digest1: '"+digest1+"'"); System.out.println("Digest2: '"+digest2+"'"); System.out.println("test1: "+DigestID.test(clearTextID, function,digest1)); System.out.println("test2: "+DigestID.test(clearTextID, digest2)); System.out.println("Digest1 != Digest2: "+DigestID.test(clearTextID, function,digest2));</code><p> To use an algorythum other than SHA-1, you will need stronger encyption. The BouncyCastle that comes with JXTA is just a minimum implimentation so a good choice is the normal bouncy castle (it is much larger, nearing a meg, which is why it is not a part of the normal JXTA distribution. The full version of bouncy includes SHA-128, SHA-256, SHA-384, and SHA-512.<p> Here is how you create a provider from the full version of Bouncy. Once you do this, you can access the extended Digest ecryption levels. <code> provider = new org.bouncycastle.jce.provider.BouncyCastleProvider(); System.out.println("provider:"+provider.getName()); Security.addProvider(provider);</code><p> Security Note<p><p> This class should have all of its fields and properties marked as 'final' to prevent overriding the default behavior. Failure to do so could allow a less scrupulous person to cause the BinaryID or hash codes to contain the original information. Note that the class itself is not final to allow for additional convienience methods to be added. There a no methods for creating ModuleClassBinaryID, ModuleSpecBinaryID, or CodatID because this is meant for general' use, not for extending platform (you can write your own using similar code). <p><P><P><DL><DT><B>Version:</B></DT> <DD>$Revision: 1.5 $</DD><DT><B>Author:</B></DT> <DD>Daniel Brookshier <a HREF="mailto:turbogeek@cluck.com">turbogeek@cluck.com</a></DD></DL><HR><P><!-- ======== NESTED CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><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>(package private) java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../net/jxta/impl/id/binaryID/DigestTool.html#algorithmType">algorithmType</A></B></CODE><BR> </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../net/jxta/impl/id/binaryID/DigestTool.html#debug">debug</A></B></CODE><BR> varaible used for conditional compile of debug printing.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../../net/jxta/impl/id/binaryID/DigestTool.html#functionSeperator">functionSeperator</A></B></CODE><BR> Tilde character used to seperate candidate strings from a function.</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="../../../../../net/jxta/impl/id/binaryID/DigestTool.html#SHA128">SHA128</A></B></CODE><BR> SHA-128 digest algorithm type. </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="../../../../../net/jxta/impl/id/binaryID/DigestTool.html#SHA256">SHA256</A></B></CODE><BR> SHA-256 digest algorithm type. </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="../../../../../net/jxta/impl/id/binaryID/DigestTool.html#SHA384">SHA384</A></B></CODE><BR> SHA-384 digest algorithm type. </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="../../../../../net/jxta/impl/id/binaryID/DigestTool.html#SHA512">SHA512</A></B></CODE><BR> SHA-512 digest algorithm type. </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="../../../../../net/jxta/impl/id/binaryID/DigestTool.html#SHAOne">SHAOne</A></B></CODE><BR> Defualt SHA-1 digest algorithm type. </TD></TR></TABLE> <!-- ======== CONSTRUCTOR SUMMARY ======== -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -