qie.pgpDecryptBytesWithoutVerify¶
Signature: qie.pgpDecryptBytesWithoutVerify(inputBytes, privateKey, privateKeyPassphrase)
Returns: byte[] decryptedBytes - the decrypted contents from the source bytes
Decrypts inputBytes using PGP encryption with the supplied private key, the signatures are NOT validated.
Note
The privateKey must be generated from a system that can generate valid PGP key pairs.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| byte[] | inputBytes | the bytes to be encrypted | |
| String, File, or byte[] | privateKey | the PGP private key to use for decrypting data | |
| String | privateKeyPassphrase | password to unlock the private key for decryption |
Example¶
// Prepare input bytes to encrypt/sign
var messageBytes = new java.lang.String(
"Top secret message: The secret lies with Charlotte."
).getBytes("utf-8");
// Example: privateKey as String path
var pgpPrivateKeyPath = "/tmp/pgpPrivate.key";
var pgpPublicKeyPath = "/tmp/pgpPublic.key";
var encryptedBytes = qie.pgpSignEncryptBytes(
messageBytes,
pgpPublicKeyPath,
pgpPrivateKeyPath,
"changeit",
true,
true
);
var decryptedBytes = qie.pgpDecryptBytesWithoutVerify(
encryptedBytes,
pgpPrivateKeyPath,
"changeit"
);
var originalMessageDecrypted = new java.lang.String(decryptedBytes, "utf-8");
// Example: privateKey as File
var pgpPrivateKeyFile = qie.newFile("/tmp/pgpPrivate.key");
var pgpPublicKeyFile = qie.newFile("/tmp/pgpPublic.key");
var encryptedBytesWithFile = qie.pgpSignEncryptBytes(
messageBytes,
pgpPublicKeyFile,
pgpPrivateKeyFile,
"changeit",
true,
true
);
var decryptedBytesWithFile = qie.pgpDecryptBytesWithoutVerify(
encryptedBytesWithFile,
pgpPrivateKeyFile,
"changeit"
);
var originalMessageWithFile = new java.lang.String(decryptedBytesWithFile, "utf-8");
// Example: privateKey as byte[]
var pgpPrivateKeyBytes = qie.readFile("/tmp/pgpPrivate.key");
var pgpPublicKeyBytes = qie.readFile("/tmp/pgpPublic.key");
var encryptedBytesWithByteKey = qie.pgpSignEncryptBytes(
messageBytes,
pgpPublicKeyBytes,
pgpPrivateKeyBytes,
"changeit",
true,
true
);
var decryptedBytesWithByteKey = qie.pgpDecryptBytesWithoutVerify(
encryptedBytesWithByteKey,
pgpPrivateKeyBytes,
"changeit"
);
var originalMessageWithByteKey = new java.lang.String(decryptedBytesWithByteKey, "utf-8");