qie.pgpEncryptBytesNoSig¶
Signature: qie.pgpEncryptBytesNoSig(inputBytes, publicKey, asciiArmored*, integrityCheck*)
Returns: byte[] encryptedBytes - the encrypted contents from the source bytes
Encrypts inputBytes using PGP encryption with the supplied public key, no signature will be generated.
Note
The publicKey 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[] | publicKey | the PGP public key to use for encryption | |
| Boolean | asciiArmored* | (optional) use PGP ascii armored, the encrypted text will be in standard ascii | false |
| Boolean | integrityCheck* | (optional) use PGP packet integrity check | false |
Example¶
// Prepare input bytes to encrypt
var messageBytes = new java.lang.String(
"Top secret message: Le secret lies with Charlotte."
).getBytes("utf-8");
// Example: publicKey as String path
var encryptedBytes = qie.pgpEncryptBytesNoSig(
messageBytes,
"/tmp/pgpPublic.key",
true,
false
);
var decryptedBytes = qie.pgpDecryptBytesWithoutVerify(
encryptedBytes,
"/tmp/pgpPrivate.key",
"changeit"
);
var originalMessage = new java.lang.String(decryptedBytes, "UTF-8");
// Example: publicKey as File
var pgpPublicKeyFile = qie.newFile("/tmp/pgpPublic.key"); // java.io.File
var encryptedBytesWithFile = qie.pgpEncryptBytesNoSig(
messageBytes,
pgpPublicKeyFile,
true,
false
);
var decryptedBytesWithFile = qie.pgpDecryptBytesWithoutVerify(
encryptedBytesWithFile,
"/tmp/pgpPrivate.key",
"changeit"
);
var originalMessageWithFile = new java.lang.String(decryptedBytesWithFile, "UTF-8");
// Example: publicKey as byte[]
var pgpPublicKeyBytes = qie.readFile("/tmp/pgpPublic.key"); // byte[]
var encryptedBytesWithBytes = qie.pgpEncryptBytesNoSig(
messageBytes,
pgpPublicKeyBytes,
true,
false
);
var decryptedBytesWithBytes = qie.pgpDecryptBytesWithoutVerify(
encryptedBytesWithBytes,
"/tmp/pgpPrivate.key",
"changeit"
);
var originalMessageWithBytes = new java.lang.String(decryptedBytesWithBytes, "UTF-8");