📄 signature.html
字号:
<A NAME="initSign(java.security.PrivateKey)"><!-- --></A><H3>initSign</H3><PRE>public final void <B>initSign</B>(<A HREF="../../java/security/PrivateKey.html">PrivateKey</A> privateKey) throws <A HREF="../../java/security/InvalidKeyException.html">InvalidKeyException</A></PRE><DL><DD>Initialize this object for signing. If this method is called again with a different argument, it negates the effect of this call.<DD><DL><DT><B>Parameters:</B><DD><CODE>privateKey</CODE> - the private key of the identity whose signature is going to be generated.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/InvalidKeyException.html">InvalidKeyException</A></CODE> - if the key is invalid.</DL></DD></DL><HR><A NAME="initSign(java.security.PrivateKey, java.security.SecureRandom)"><!-- --></A><H3>initSign</H3><PRE>public final void <B>initSign</B>(<A HREF="../../java/security/PrivateKey.html">PrivateKey</A> privateKey, <A HREF="../../java/security/SecureRandom.html">SecureRandom</A> random) throws <A HREF="../../java/security/InvalidKeyException.html">InvalidKeyException</A></PRE><DL><DD>Initialize this object for signing. If this method is called again with a different argument, it negates the effect of this call.<DD><DL><DT><B>Parameters:</B><DD><CODE>privateKey</CODE> - the private key of the identity whose signature is going to be generated.<DD><CODE>random</CODE> - the source of randomness for this signature.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/InvalidKeyException.html">InvalidKeyException</A></CODE> - if the key is invalid.</DL></DD></DL><HR><A NAME="sign()"><!-- --></A><H3>sign</H3><PRE>public final byte[] <B>sign</B>() throws <A HREF="../../java/security/SignatureException.html">SignatureException</A></PRE><DL><DD>Returns the signature bytes of all the data updated. The format of the signature depends on the underlying signature scheme. <p>A call to this method resets this signature object to the state it was in when previously initialized for signing via a call to <code>initSign(PrivateKey)</code>. That is, the object is reset and available to generate another signature from the same signer, if desired, via new calls to <code>update</code> and <code>sign</code>.<DD><DL><DT><B>Returns:</B><DD>the signature bytes of the signing operation's result.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/SignatureException.html">SignatureException</A></CODE> - if this signature object is not initialized properly.</DL></DD></DL><HR><A NAME="sign(byte[], int, int)"><!-- --></A><H3>sign</H3><PRE>public final int <B>sign</B>(byte[] outbuf, int offset, int len) throws <A HREF="../../java/security/SignatureException.html">SignatureException</A></PRE><DL><DD>Finishes the signature operation and stores the resulting signature bytes in the provided buffer <code>outbuf</code>, starting at <code>offset</code>. The format of the signature depends on the underlying signature scheme. <p>This signature object is reset to its initial state (the state it was in after a call to one of the <code>initSign</code> methods) and can be reused to generate further signatures with the same private key.<DD><DL><DT><B>Parameters:</B><DD><CODE>outbuf</CODE> - buffer for the signature result.<DD><CODE>offset</CODE> - offset into <code>outbuf</code> where the signature is stored.<DD><CODE>len</CODE> - number of bytes within <code>outbuf</code> allotted for the signature.<DT><B>Returns:</B><DD>the number of bytes placed into <code>outbuf</code>.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/SignatureException.html">SignatureException</A></CODE> - if an error occurs or <code>len</code> is less than the actual signature length.<DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="verify(byte[])"><!-- --></A><H3>verify</H3><PRE>public final boolean <B>verify</B>(byte[] signature) throws <A HREF="../../java/security/SignatureException.html">SignatureException</A></PRE><DL><DD>Verifies the passed-in signature. <p>A call to this method resets this signature object to the state it was in when previously initialized for verification via a call to <code>initVerify(PublicKey)</code>. That is, the object is reset and available to verify another signature from the identity whose public key was specified in the call to <code>initVerify</code>.<DD><DL><DT><B>Parameters:</B><DD><CODE>signature</CODE> - the signature bytes to be verified.<DT><B>Returns:</B><DD>true if the signature was verified, false if not.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/SignatureException.html">SignatureException</A></CODE> - if this signature object is not initialized properly, or the passed-in signature is improperly encoded or of the wrong type, etc.</DL></DD></DL><HR><A NAME="update(byte)"><!-- --></A><H3>update</H3><PRE>public final void <B>update</B>(byte b) throws <A HREF="../../java/security/SignatureException.html">SignatureException</A></PRE><DL><DD>Updates the data to be signed or verified by a byte.<DD><DL><DT><B>Parameters:</B><DD><CODE>b</CODE> - the byte to use for the update.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/SignatureException.html">SignatureException</A></CODE> - if this signature object is not initialized properly.</DL></DD></DL><HR><A NAME="update(byte[])"><!-- --></A><H3>update</H3><PRE>public final void <B>update</B>(byte[] data) throws <A HREF="../../java/security/SignatureException.html">SignatureException</A></PRE><DL><DD>Updates the data to be signed or verified, using the specified array of bytes.<DD><DL><DT><B>Parameters:</B><DD><CODE>data</CODE> - the byte array to use for the update.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/SignatureException.html">SignatureException</A></CODE> - if this signature object is not initialized properly.</DL></DD></DL><HR><A NAME="update(byte[], int, int)"><!-- --></A><H3>update</H3><PRE>public final void <B>update</B>(byte[] data, int off, int len) throws <A HREF="../../java/security/SignatureException.html">SignatureException</A></PRE><DL><DD>Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset.<DD><DL><DT><B>Parameters:</B><DD><CODE>data</CODE> - the array of bytes.<DD><CODE>off</CODE> - the offset to start from in the array of bytes.<DD><CODE>len</CODE> - the number of bytes to use, starting at offset.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/SignatureException.html">SignatureException</A></CODE> - if this signature object is not initialized properly.</DL></DD></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 the name of the algorithm for this signature object.<DD><DL><DT><B>Returns:</B><DD>the name of the algorithm for this signature object.</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 signature object, providing information that includes the state of the object and the name of the algorithm used.<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><DL><DT><B>Returns:</B><DD>a string representation of this signature object.</DL></DD></DL><HR><A NAME="setParameter(java.lang.String, java.lang.Object)"><!-- --></A><H3>setParameter</H3><PRE>public final void <B>setParameter</B>(<A HREF="../../java/lang/String.html">String</A> param, <A HREF="../../java/lang/Object.html">Object</A> value) throws <A HREF="../../java/security/InvalidParameterException.html">InvalidParameterException</A></PRE><DL><DD><B>Deprecated.</B> <I>Use <A HREF="../../java/security/Signature.html#setParameter(java.security.spec.AlgorithmParameterSpec)"><CODE>setParameter</CODE></A>.</I><P><DD>Sets the specified algorithm parameter to the specified value. This method supplies a general-purpose mechanism through which it is possible to set the various parameters of this object. A parameter may be any settable parameter for the algorithm, such as a parameter size, or a source of random bits for signature generation (if appropriate), or an indication of whether or not to perform a specific but optional computation. A uniform algorithm-specific naming scheme for each parameter is desirable but left unspecified at this time.<DD><DL><DT><B>Parameters:</B><DD><CODE>param</CODE> - the string identifier of the parameter.<DD><CODE>value</CODE> - the parameter value.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/InvalidParameterException.html">InvalidParameterException</A></CODE> - if <code>param</code> is an invalid parameter for this signature algorithm engine, the parameter is already set and cannot be set again, a security exception occurs, and so on.</DL></DD></DL><HR><A NAME="setParameter(java.security.spec.AlgorithmParameterSpec)"><!-- --></A><H3>setParameter</H3><PRE>public final void <B>setParameter</B>(<A HREF="../../java/security/spec/AlgorithmParameterSpec.html">AlgorithmParameterSpec</A> params) throws <A HREF="../../java/security/InvalidAlgorithmParameterException.html">InvalidAlgorithmParameterException</A></PRE><DL><DD>Initializes this signature engine with the specified parameter set.<DD><DL><DT><B>Parameters:</B><DD><CODE>params</CODE> - the parameters<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/InvalidAlgorithmParameterException.html">InvalidAlgorithmParameterException</A></CODE> - if the given parameters are inappropriate for this signature engine</DL></DD></DL><HR><A NAME="getParameter(java.lang.String)"><!-- --></A><H3>getParameter</H3><PRE>public final <A HREF="../../java/lang/Object.html">Object</A> <B>getParameter</B>(<A HREF="../../java/lang/String.html">String</A> param) throws <A HREF="../../java/security/InvalidParameterException.html">InvalidParameterException</A></PRE><DL><DD><B>Deprecated.</B> <I></I> <P><DD>Gets the value of the specified algorithm parameter. This method supplies a general-purpose mechanism through which it is possible to get the various parameters of this object. A parameter may be any settable parameter for the algorithm, such as a parameter size, or a source of random bits for signature generation (if appropriate), or an indication of whether or not to perform a specific but optional computation. A uniform algorithm-specific naming scheme for each parameter is desirable but left unspecified at this time.<DD><DL><DT><B>Parameters:</B><DD><CODE>param</CODE> - the string name of the parameter.<DT><B>Returns:</B><DD>the object that represents the parameter value, or null if there is none.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/security/InvalidParameterException.html">InvalidParameterException</A></CODE> - if <code>param</code> is an invalid parameter for this engine, or another exception occurs while trying to get this parameter.</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/SignatureSpi.html#clone()">clone</A></CODE> in class <CODE><A HREF="../../java/security/SignatureSpi.html">SignatureSpi</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/Signature.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/SecurityPermission.html"><B>PREV CLASS</B></A> <A HREF="../../java/security/SignatureSpi.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="Signature.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><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 + -