Skip to content

daggerok/java-rsa-pem-pkcs8-pk8-public-private-keys

Repository files navigation

java certificates and public / private keys CI

rsa-asymmetric-cryptography

TODO...

./mvnw -f rsa-asymmetric-cryptography clean package dependency:copy-dependencies -DincludeScope=runtime
java -cp "rsa-asymmetric-cryptography/target/dependency/*:rsa-asymmetric-cryptography/target/classes" daggerok.Main

java -cp "rsa-asymmetric-cryptography/target/dependency/*:rsa-asymmetric-cryptography/target/classes" daggerok.Main generate and write
java -cp "rsa-asymmetric-cryptography/target/dependency/*:rsa-asymmetric-cryptography/target/classes" daggerok.Main read

export encrypted=`java -cp "rsa-asymmetric-cryptography/target/dependency/*:rsa-asymmetric-cryptography/target/classes" daggerok.Main encrypt --payload="Hello, World"`
echo "encrypted value is $encrypted"

export decrypted=`java -cp "rsa-asymmetric-cryptography/target/dependency/*:rsa-asymmetric-cryptography/target/classes" daggerok.Main decrypt --payload="$encrypted"`
echo "decrypted value is $decrypted"

consume-keys-files

./mvnw clean compile -f consume-keys-files

openssl genrsa -out consume-keys-files/target/private_rsa_key.pem 4096
openssl rsa -pubout -in consume-keys-files/target/private_rsa_key.pem -out consume-keys-files/target/public_key.pem
openssl pkcs8 -topk8 -in consume-keys-files/target/private_rsa_key.pem -inform pem -out consume-keys-files/target/private_key.pem -outform pem -nocrypt

java -cp consume-keys-files/target/classes consumekeysfiles.Main --public=consume-keys-files/target/public_key.pem --private=./consume-keys-files/target/private_key.pem

TODO: Write app to generate keys (files?) from java for later use

aes-encryption

./mvnw clean compile -f aes-encryption

java -cp aes-encryption/target/classes aesencryption.Main --encrypt=ololo
java -cp aes-encryption/target/classes aesencryption.Main --decrypt=9T3d2eg/O8ntHYO1UXdDZg==

AES in java

rsa-key-pair-generation

./mvnw clean compile -f rsa-key-pair-generation

java -cp `pwd`/rsa-key-pair-generation/target/classes rsakeypairgeneration.Main --keySize=1024

RSA Encryption in Javascript and Decryption in Java