public class DigitalSignature extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ALGORITHM
The digital signature algorithm to use: "SHA256withRSAandMGF1".
|
| Modifier | Constructor and Description |
|---|---|
|
DigitalSignature()
The default constructor initialises the instance with the "SHA256withRSAandMGF1" algorithm.
|
protected |
DigitalSignature(String algorithm)
This constructor is protected so that, should you need a different algorithm (e.g.
|
| Modifier and Type | Method and Description |
|---|---|
protected Signature |
getSignature() |
String |
sign(InputStream content,
PrivateKey privateKey)
Generates a digital signature for the given
InputStream. |
String |
sign(String content,
PrivateKey privateKey)
Generates a digital signature for the given string.
|
boolean |
verify(InputStream input,
PublicKey publicKey,
String signature) |
boolean |
verify(String content,
PublicKey publicKey,
String signature)
Verifies whether the given content matches the given signature.
|
public static final String ALGORITHM
public DigitalSignature()
protected DigitalSignature(String algorithm)
algorithm - This should normally be "SHA256withRSAandMGF1".public String sign(String content, PrivateKey privateKey)
content - The string to be digitally signed.privateKey - The PrivateKey with which the string is to be signed. This can be obtained
via Keys.newKeyPair().public String sign(InputStream content, PrivateKey privateKey)
InputStream.content - The input to be digitally signed.privateKey - The PrivateKey with which the input is to be signed. This can be obtained
via Keys.newKeyPair().public boolean verify(String content, PublicKey publicKey, String signature)
content - The content to be verified.publicKey - The public key to use in the verification process.signature - The signature with which the content is to be verified. This can be obtained via
Keys.newKeyPair().public boolean verify(InputStream input, PublicKey publicKey, String signature)
input - The content for which the signature is to be verified.publicKey - The PublicKey corresponding to the PrivateKey that was used to
sign the content. This can be obtained via Keys.newKeyPair().signature - The signature to be verified.Copyright © 2015 Carboni. All rights reserved.