Start of Tutorial > Start of Trail |
Search
Feedback Form |
This lesson walks you through the steps necessary to use the Java Security API to generate a digital signature for data, and to verify that a signature is authentic.
In this lesson, we create a Java application named
testSig
that uses the Digital Signature Algorithm (DSA) to sign data contained in a file. The application gets the file name from the command line.The steps to create our sample program to sign and verify data using the Security API are the following:
Create a text file namedtestSig.java
. Type in the initial program structure (import statements, class name,main
method, and so on).
Generate a key pair (public key and private key). The private key is needed for signing the data, the public key for verifying the signature.
Get a Signature object that can generate and verify signatures. Initialize it, supply it the data to be signed, and generate the signature.
Initialize the Signature object for verifying the signature. Supply the Signature object the data that was signed, the public key, and the signature, and ask it to do the verification.
Use javac
to compile the Java program created in the previous steps.
And finally, use java
, the Java interpreter, to run the program.
Start of Tutorial > Start of Trail |
Search
Feedback Form |
Copyright 1995-2002 Sun Microsystems, Inc. All rights reserved.