VerSig
program
you will generate in the upcoming
Verifying a Digital Signature
steps. That program uses the public key
to verify that the signature received is the true signature for the
data received.
Recall that the signature was placed in a byte array named realSig
.
You can save the signature bytes in a file named sig
via the following.
/* save the signature in a file */ FileOutputStream sigfos = new FileOutputStream("sig"); sigfos.write(realSig); sigfos.close();
pub
.
You can get the encoded key bytes by calling the getEncoded
method and then store the encoded bytes in a file. You can name the file
whatever you want. If, for example, your name is Susan, you might
name it something like suepk
(for "Sue's public key"),
as in the following:
/* save the public key in a file */ byte[] key = pub.getEncoded(); FileOutputStream keyfos = new FileOutputStream("suepk"); keyfos.write(key); keyfos.close();