public interface Crypto
| Modifier and Type | Method and Description |
|---|---|
Fingerprint |
calculateFingerprint(byte[] content)
Calculate fingerprint.
|
byte[] |
computeHash(byte[] data,
HashAlgorithm algorithm)
Compute data hash with algorithm specified.
|
byte[] |
decrypt(byte[] data,
PrivateKey privateKey)
Decrypt byte array with private key.
|
void |
decrypt(InputStream inputStream,
OutputStream outputStream,
PrivateKey privateKey)
Decrypt stream data with private key.
|
byte[] |
decryptThenVerify(byte[] cipherData,
PrivateKey privateKey,
PublicKey publicKey)
Decrypt data and verify.
|
byte[] |
encrypt(byte[] data,
PublicKey recipient)
Encrypt byte array for single recipient.
|
byte[] |
encrypt(byte[] data,
PublicKey[] recipients)
Encrypt byte array with public key set.
|
void |
encrypt(InputStream inputStream,
OutputStream outputStream,
PublicKey recipient)
Encrypt stream data with public key.
|
void |
encrypt(InputStream inputStream,
OutputStream outputStream,
PublicKey[] recipients)
Encrypt stream data with public key set.
|
byte[] |
exportPrivateKey(PrivateKey privateKey)
Export private key as byte array.
|
byte[] |
exportPrivateKey(PrivateKey privateKey,
String password)
Export private key as byte array.
|
byte[] |
exportPublicKey(PublicKey publicKey)
Export public key as byte array.
|
PublicKey |
extractPublicKey(PrivateKey privateKey)
Extract public key from private key.
|
KeyPair |
generateKeys()
Generate key pair.
|
PrivateKey |
importPrivateKey(byte[] keyData)
Import private key from byte array.
|
PrivateKey |
importPrivateKey(byte[] keyData,
String password)
Import private key from byte array.
|
PublicKey |
importPublicKey(byte[] publicKey)
Import public key from byte array.
|
byte[] |
sign(byte[] data,
PrivateKey privateKey)
Sign byte array data with private key.
|
byte[] |
sign(InputStream inputStream,
PrivateKey privateKey)
Sign stream data with private key.
|
byte[] |
signThenEncrypt(byte[] data,
PrivateKey privateKey,
PublicKey recipient)
Sign data and encrypt.
|
byte[] |
signThenEncrypt(byte[] data,
PrivateKey privateKey,
PublicKey[] recipients)
Sign data and encrypt.
|
boolean |
verify(byte[] data,
byte[] signature,
PublicKey signer)
Verify byte array with signature.
|
boolean |
verify(InputStream inputStream,
byte[] signature,
PublicKey signer)
Verify stream data with signature.
|
Fingerprint calculateFingerprint(byte[] content)
content - The data to calculate fingerprint for.String.byte[] computeHash(byte[] data,
HashAlgorithm algorithm)
data - the data for hashing.algorithm - the algorithm to be used for hash calculation.byte[] decrypt(byte[] data,
PrivateKey privateKey)
data - the data to be decrypted.privateKey - the recipients private key.void decrypt(InputStream inputStream, OutputStream outputStream, PrivateKey privateKey)
inputStream - the input stream to be decrypted.outputStream - the decrypted data as stream.privateKey - the recipients private key.DecryptionExceptionPublicKey,
PrivateKeybyte[] encrypt(byte[] data,
PublicKey recipient)
data - the data to be encrypted.recipient - the recipient's public key.PublicKeybyte[] encrypt(byte[] data,
PublicKey[] recipients)
data - the data to be encrypted.recipients - the recipients public key set.PublicKeyvoid encrypt(InputStream inputStream, OutputStream outputStream, PublicKey recipient)
inputStream - the input stream to be encrypted.outputStream - the output stream encrypted data written to.recipient - the recipient's public key.EncryptionException - if encryption failed.void encrypt(InputStream inputStream, OutputStream outputStream, PublicKey[] recipients)
inputStream - the input stream to be encrypted.outputStream - the output stream encrypted data written to.recipients - the recipients public key set.EncryptionException - if encryption failed.byte[] exportPrivateKey(PrivateKey privateKey)
privateKey - the private key.PrivateKeybyte[] exportPrivateKey(PrivateKey privateKey, String password)
privateKey - the private key.password - the private key password.PrivateKeybyte[] exportPublicKey(PublicKey publicKey)
publicKey - the public key.PublicKeyPublicKey extractPublicKey(PrivateKey privateKey)
privateKey - the private key.KeyPair generateKeys()
PrivateKey,
PublicKeyPrivateKey importPrivateKey(byte[] keyData)
keyData - the Base64 encoded private key.CryptoException - if private key couldn't be imported.PrivateKeyPrivateKey importPrivateKey(byte[] keyData, String password)
keyData - the Base64 encoded private key.password - the private key password.CryptoException - if private key couldn't be imported.PrivateKeyPublicKey importPublicKey(byte[] publicKey)
publicKey - the public key.PublicKeybyte[] sign(byte[] data,
PrivateKey privateKey)
data - the data to be signed.privateKey - the signer's private key.PrivateKeybyte[] sign(InputStream inputStream, PrivateKey privateKey)
inputStream - the input stream to be signed.privateKey - the signer's private key.SigningException - if stream couldn't be signed.PrivateKeyboolean verify(byte[] data,
byte[] signature,
PublicKey signer)
data - the data to be verified.signature - the signature.signer - the signer's public key.true if signature is valid. false in other case.VerificationException - if data couldn't be verified.boolean verify(InputStream inputStream, byte[] signature, PublicKey signer)
inputStream - the input stream to be verified.signature - the signature.signer - the signer's public key.true if signature is valid. false in other case.VerificationException - if data couldn't be verified.byte[] signThenEncrypt(byte[] data,
PrivateKey privateKey,
PublicKey recipient)
data - the data to be signed and encrypted.privateKey - the private key used for signing.recipient - the recipient's public key.byte[] signThenEncrypt(byte[] data,
PrivateKey privateKey,
PublicKey[] recipients)
data - the data to be signed and encrypted.privateKey - the private key used for signing.recipients - the recipient public keys.byte[] decryptThenVerify(byte[] cipherData,
PrivateKey privateKey,
PublicKey publicKey)
cipherData - the encrypted data to be decrypted.privateKey - the private key used for decryption.publicKey - the public key used for verify.Copyright © 2016. All rights reserved.