📄 messagedigest.html
字号:
</TABLE> <P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TD></TR></TABLE><A NAME="MessageDigest(java.lang.String)"><!-- --></A><H3>MessageDigest</H3><PRE>protected <B>MessageDigest</B>(<A HREF="../../java/lang/String.html">String</A> algorithm)</PRE><DL><DD>Creates a message digest with the specified algorithm name.<DD><DL><DT><B>Parameters:</B><DD><CODE>algorithm</CODE> - the standard name of the digest algorithm. See Appendix A in the <a href= "../../../guide/security/CryptoSpec.html#AppA"> Java Cryptography Architecture API Specification & Reference </a> for information about standard algorithm names.</DL></DD></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="getInstance(java.lang.String)"><!-- --></A><H3>getInstance</H3><PRE>public static <A HREF="../../java/security/MessageDigest.html">MessageDigest</A> <B>getInstance</B>(<A HREF="../../java/lang/String.html">String</A> algorithm) throws <A HREF="../../java/security/NoSuchAlgorithmException.html">NoSuchAlgorithmException</A></PRE><DL><DD>Generates a MessageDigest object that implements the specified digest algorithm. If the default provider package provides an implementation of the requested digest algorithm, an instance of MessageDigest containing that implementation is returned. If the algorithm is not available in the default package, other packages are searched.<DD><DL><DT><B>Parameters:</B><DD><CODE>algorithm</CODE> - the name of the algorithm requested. See Appendix A in the <a href= "../../../guide/security/CryptoSpec.html#AppA"> Java Cryptography Architecture API Specification & Reference </a> for information about standard algorithm names.<DT><B>Returns:</B><DD>a Message Digest object implementing the specified algorithm.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/NoSuchAlgorithmException.html">NoSuchAlgorithmException</A></CODE> - if the algorithm is not available in the caller's environment.</DL></DD></DL><HR><A NAME="getInstance(java.lang.String, java.lang.String)"><!-- --></A><H3>getInstance</H3><PRE>public static <A HREF="../../java/security/MessageDigest.html">MessageDigest</A> <B>getInstance</B>(<A HREF="../../java/lang/String.html">String</A> algorithm, <A HREF="../../java/lang/String.html">String</A> provider) throws <A HREF="../../java/security/NoSuchAlgorithmException.html">NoSuchAlgorithmException</A>, <A HREF="../../java/security/NoSuchProviderException.html">NoSuchProviderException</A></PRE><DL><DD>Generates a MessageDigest object implementing the specified algorithm, as supplied from the specified provider, if such an algorithm is available from the provider.<DD><DL><DT><B>Parameters:</B><DD><CODE>algorithm</CODE> - the name of the algorithm requested. See Appendix A in the <a href= "../../../guide/security/CryptoSpec.html#AppA"> Java Cryptography Architecture API Specification & Reference </a> for information about standard algorithm names.<DD><CODE>provider</CODE> - the name of the provider.<DT><B>Returns:</B><DD>a Message Digest object implementing the specified algorithm.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/NoSuchAlgorithmException.html">NoSuchAlgorithmException</A></CODE> - if the algorithm is not available in the package supplied by the requested provider.<DD><CODE><A HREF="../../java/security/NoSuchProviderException.html">NoSuchProviderException</A></CODE> - if the provider is not available in the environment.<DT><B>See Also: </B><DD><A HREF="../../java/security/Provider.html"><CODE>Provider</CODE></A></DL></DD></DL><HR><A NAME="getProvider()"><!-- --></A><H3>getProvider</H3><PRE>public final <A HREF="../../java/security/Provider.html">Provider</A> <B>getProvider</B>()</PRE><DL><DD>Returns the provider of this message digest object.<DD><DL><DT><B>Returns:</B><DD>the provider of this message digest object</DL></DD></DL><HR><A NAME="update(byte)"><!-- --></A><H3>update</H3><PRE>public void <B>update</B>(byte input)</PRE><DL><DD>Updates the digest using the specified byte.<DD><DL><DT><B>Parameters:</B><DD><CODE>input</CODE> - the byte with which to update the digest.</DL></DD></DL><HR><A NAME="update(byte[], int, int)"><!-- --></A><H3>update</H3><PRE>public void <B>update</B>(byte[] input, int offset, int len)</PRE><DL><DD>Updates the digest using the specified array of bytes, starting at the specified offset.<DD><DL><DT><B>Parameters:</B><DD><CODE>input</CODE> - the array of bytes.<DD><CODE>offset</CODE> - the offset to start from in the array of bytes.<DD><CODE>len</CODE> - the number of bytes to use, starting at <code>offset</code>.</DL></DD></DL><HR><A NAME="update(byte[])"><!-- --></A><H3>update</H3><PRE>public void <B>update</B>(byte[] input)</PRE><DL><DD>Updates the digest using the specified array of bytes.<DD><DL><DT><B>Parameters:</B><DD><CODE>input</CODE> - the array of bytes.</DL></DD></DL><HR><A NAME="digest()"><!-- --></A><H3>digest</H3><PRE>public byte[] <B>digest</B>()</PRE><DL><DD>Completes the hash computation by performing final operations such as padding. The digest is reset after this call is made.<DD><DL><DT><B>Returns:</B><DD>the array of bytes for the resulting hash value.</DL></DD></DL><HR><A NAME="digest(byte[], int, int)"><!-- --></A><H3>digest</H3><PRE>public int <B>digest</B>(byte[] buf, int offset, int len) throws <A HREF="../../java/security/DigestException.html">DigestException</A></PRE><DL><DD>Completes the hash computation by performing final operations such as padding. The digest is reset after this call is made.<DD><DL><DT><B>Parameters:</B><DD><CODE>buf</CODE> - output buffer for the computed digest<DD><CODE>offset</CODE> - offset into the output buffer to begin storing the digest<DD><CODE>len</CODE> - number of bytes within buf allotted for the digest<DT><B>Returns:</B><DD>the number of bytes placed into <code>buf</code><DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/DigestException.html">DigestException</A></CODE> - if an error occurs.</DL></DD></DL><HR><A NAME="digest(byte[])"><!-- --></A><H3>digest</H3><PRE>public byte[] <B>digest</B>(byte[] input)</PRE><DL><DD>Performs a final update on the digest using the specified array of bytes, then completes the digest computation. That is, this method first calls <A HREF="../../java/security/MessageDigest.html#update(byte[])"><CODE>update(input)</CODE></A>, passing the <i>input</i> array to the <code>update</code> method, then calls <A HREF="../../java/security/MessageDigest.html#digest()"><CODE>digest()</CODE></A>.<DD><DL><DT><B>Parameters:</B><DD><CODE>input</CODE> - the input to be updated before the digest is completed.<DT><B>Returns:</B><DD>the array of bytes for the resulting hash value.</DL></DD></DL><HR><A NAME="toString()"><!-- --></A><H3>toString</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>toString</B>()</PRE><DL><DD>Returns a string representation of this message digest object.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#toString()">toString</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL></DD><DD>Following copied from class: <CODE>java.lang.Object</CODE></DD><DD><DL><DT><B>Returns:</B><DD>a string representation of the object.</DL></DD></DL><HR><A NAME="isEqual(byte[], byte[])"><!-- --></A><H3>isEqual</H3><PRE>public static boolean <B>isEqual</B>(byte[] digesta, byte[] digestb)</PRE><DL><DD>Compares two digests for equality. Does a simple byte compare.<DD><DL><DT><B>Parameters:</B><DD><CODE>digesta</CODE> - one of the digests to compare.<DD><CODE>digestb</CODE> - the other digest to compare.<DT><B>Returns:</B><DD>true if the digests are equal, false otherwise.</DL></DD></DL><HR><A NAME="reset()"><!-- --></A><H3>reset</H3><PRE>public void <B>reset</B>()</PRE><DL><DD>Resets the digest for further use.</DL><HR><A NAME="getAlgorithm()"><!-- --></A><H3>getAlgorithm</H3><PRE>public final <A HREF="../../java/lang/String.html">String</A> <B>getAlgorithm</B>()</PRE><DL><DD>Returns a string that identifies the algorithm, independent of implementation details. The name should be a standard Java Security name (such as "SHA", "MD5", and so on). See Appendix A in the <a href= "../../../guide/security/CryptoSpec.html#AppA"> Java Cryptography Architecture API Specification & Reference </a> for information about standard algorithm names.<DD><DL><DT><B>Returns:</B><DD>the name of the algorithm</DL></DD></DL><HR><A NAME="getDigestLength()"><!-- --></A><H3>getDigestLength</H3><PRE>public final int <B>getDigestLength</B>()</PRE><DL><DD>Returns the length of the digest in bytes, or 0 if this operation is not supported by the provider and the implementation is not cloneable.<DD><DL><DT><B>Returns:</B><DD>the digest length in bytes, or 0 if this operation is not supported by the provider and the implementation is not cloneable.<DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="clone()"><!-- --></A><H3>clone</H3><PRE>public <A HREF="../../java/lang/Object.html">Object</A> <B>clone</B>() throws <A HREF="../../java/lang/CloneNotSupportedException.html">CloneNotSupportedException</A></PRE><DL><DD>Returns a clone if the implementation is cloneable.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/security/MessageDigestSpi.html#clone()">clone</A></CODE> in class <CODE><A HREF="../../java/security/MessageDigestSpi.html">MessageDigestSpi</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>a clone if the implementation is cloneable.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/CloneNotSupportedException.html">CloneNotSupportedException</A></CODE> - if this is called on an implementation that does not support <code>Cloneable</code>.</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <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/MessageDigest.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-files/index-1.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><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../java/security/KeyStoreSpi.html"><B>PREV CLASS</B></A> <A HREF="../../java/security/MessageDigestSpi.html"><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="MessageDigest.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -