crc-24 ^
returns the crc24 checksum
(crc-24 (byte-array [100 100 100 100 100 100]))
=> ["=6Fko" [-24 89 40] 15227176]
decrypt ^
decrypts the encrypted information
(-> (.getBytes "Hello World")
(encrypt {:public +public-key+})
(decrypt {:private +private-key+})
(String.))
=> "Hello World"
encrypt ^
encrypts bytes given a public key
(->> (encrypt (.getBytes "Hello World")
{:public +public-key+})
(encode/to-base64))
fingerprint ^
returns the fingerprint of a public key
(fingerprint +public-key+)
=> "E710D59C5346D3C0A1C578AE6753F8E16D35FC24"
generate-signature ^
generates a signature given bytes and a keyring
(generate-signature (.getBytes "Hello World")
{:public +public-key+
:private +private-key+})
;; #gpg.signature ["iQEcBAABCAAGBQJbw1U8AAoJEGdT+OFtNf... "]
=> org.bouncycastle.openpgp.PGPSignature
key-pair ^
returns a public and private key pair from a secret key
(key-pair +secret-key+)
;;[#public "E710D59C5346D3C0A1C578AE6753F8E16D35FC24" #private "7445568256057146404"]
=> (contains [org.bouncycastle.openpgp.PGPPublicKey
org.bouncycastle.openpgp.PGPPrivateKey])
parse-public-key ^
parses a public key from string
(-> (string/joinl +public-key-string+ "n")
(parse-public-key))
;; #public "E710D59C5346D3C0A1C578AE6753F8E16D35FC24"
=> org.bouncycastle.openpgp.PGPPublicKey
parse-public-key-ring ^
parses a public key ring from string
(-> (string/joinl +public-key-string+ "n")
(parse-public-key-ring))
=> org.bouncycastle.openpgp.PGPPublicKeyRing
parse-secret-key ^
parses a secret key from string
(-> (string/joinl +secret-key-string+ "n")
(parse-secret-key))
;; #secret "E710D59C5346D3C0A1C578AE6753F8E16D35FC24"
=> org.bouncycastle.openpgp.PGPSecretKey
parse-secret-key-ring ^
parses a secret key ring from string
(-> (string/joinl +secret-key-string+ "n")
(parse-secret-key-ring))
=> org.bouncycastle.openpgp.PGPSecretKeyRing
pgp-signature ^
returns a gpg signature from encoded bytes
(-> (generate-signature (.getBytes "Hello World")
{:public +public-key+
:private +private-key+})
(.getEncoded)
(pgp-signature))
=> org.bouncycastle.openpgp.PGPSignature
read-sig-file ^
reads bytes from a GPG compatible file
(read-sig-file "dev/scratch/project.clj.asc")
=> bytes?
sign ^
generates a output gpg signature for an input file
(sign "project.clj"
"dev/scratch/project.clj.asc"
{:public +public-key+
:private +private-key+})
=> bytes?
verify ^
verifies that the signature works
(verify "project.clj"
"dev/scratch/project.clj.asc"
{:public +public-key+})
=> true
write-sig-file ^
writes bytes to a GPG compatible file
(let [signature (-> (generate-signature (.getBytes "Hello World")
{:public +public-key+
:private +private-key+})
(.getEncoded))]
(write-sig-file "dev/scratch/project.clj.asc"
signature))