io.github.no-such-company:pgplug

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

GroupId

GroupId

io.github.no-such-company
ArtifactId

ArtifactId

pgplug
Last Version

Last Version

21.5
Release Date

Release Date

Type

Type

jar
Description

Description

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

Download pgplug

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.no-such-company/pgplug/ -->
<dependency>
    <groupId>io.github.no-such-company</groupId>
    <artifactId>pgplug</artifactId>
    <version>21.5</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.no-such-company/pgplug/
implementation 'io.github.no-such-company:pgplug:21.5'
// https://jarcasting.com/artifacts/io.github.no-such-company/pgplug/
implementation ("io.github.no-such-company:pgplug:21.5")
'io.github.no-such-company:pgplug:jar:21.5'
<dependency org="io.github.no-such-company" name="pgplug" rev="21.5">
  <artifact name="pgplug" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.no-such-company', module='pgplug', version='21.5')
)
libraryDependencies += "io.github.no-such-company" % "pgplug" % "21.5"
[io.github.no-such-company/pgplug "21.5"]

Dependencies

compile (1)

Group / Artifact Type Version
org.bouncycastle : bcpg-jdk15on jar 1.57

test (1)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.7.0

Project Modules

There are no modules declared in this project.

PGPlug

A PGP plugin for Java project to make the use of PGP painless and easy.

Test Java CI with Maven

This package uses Bouncycastel for PGP encryption. Due to the high demands on PGP it is sometimes not possible to realize projects without high expertise.

Swen Kalski designed this package for the BlackChamber server and makes it universally usable for JAVA and Android projects with this repository.

Install

Maven:

<dependency>
  <groupId>io.github.no-such-company</groupId>
  <artifactId>pgplug</artifactId>
  <version>21.5</version>
</dependency>

Gradle:

repositories {
	mavenCentral()
}

dependencies {
	implementation 'io.github.no-such-company:pgplug:21.5'
}

Basic usage

create keys

Keys can be written directly to a file.

String pass = "something123".toCharArray();

OutputStream privateOut = new FileOutputStream("test.prv");
OutputStream publicOut = new FileOutputStream("test.pub");

generateKeyPair(privateOut, publicOut, pass);

read keys

FileInputStream publicKeyInputStream = new FileInputStream("test.pub");
PGPPublicKey publicKeyRing = readPublicKey(publicKeyInputStream);

FileInputStream privateKeyInputStream = new FileInputStream("test.prv");
PGPSecretKey privateKeyRing = readSecretKey(privateKeyInputStream);

encrytpData

Encrypt a plain Text with a set (or one) public key

The Encrypt method support plaintext with char[] as same as inputStream()

public static byte[] encrypt(byte[] clearData, byte[]... publicKeys)
public static void encrypt(
OutputStream out,
byte[] clearData,
Collection<PGPPublicKey> publicKeys
)
        

Example:

final byte[] clearData = "1234567890".getBytes();

FileInputStream publicKeyInputStream = new FileInputStream("test.pub");
ByteArrayOutputStream encrypted_output = new ByteArrayOutputStream();

Set<PGPPublicKey> publicKeys = new HashSet<PGPPublicKey>();
publicKeys.add(readPublicKey(publicKeyInputStream));

PGPUtils.encrypt(encrypted_output, clearData, publicKeys);

// now you can save encryted_output

decryptData

Decrypt data with the private key (secret). decrypt_outputstream support OutputStream and char[]

PGPUtils.decrypt(
        encryptedByteArray,
        readSecretKey(privateKeyInputStream),
        decrypt_outputStream, 
        pass);

signData

A file can be signed with a private key. If you are lazy you can simply overwrite the encrypted file with the signed encrypted file

SignedFileProcessor.signFile(
                encryptedFileDest, //a String with the destination of the encryted file wich has to be signed
                new FileInputStream(privateKeyDest), //The InputStream of the private (secret) key
                new FileOutputStream(encryptedSignedFileDest), //The Outputstream of the signed file
                pass, // the char[] of the secret key password
                true amor (leave true if you got no idea)
        );

verify signed file

The verifyFile() check the signature against a public key. It returns a boolean

SignedFileProcessor.verifyFile(
        new FileInputStream(encryptedSignedFileDestination),
        new FileInputStream(publicKey_of_the_sign)
        );
io.github.no-such-company

no such Company

Secure Mail project github host

Versions

Version
21.5
21.4
21.3
21.2