Liking cljdoc? Tell your friends :D
All platforms.

uniformity.crypto.cryptopack


decryptclj/s

(decrypt ciphertext
         &
         {:keys [aes-key password rsa-privkey output] :or {output :bytes}})

Decrypt ciphertext using one of the provided keys.

ciphertext parameter is a cryptopack in the form of either:

  • a map
  • a string (compacted and JSON-encoded)
  • a byte array (compacted and messagepack-encoded)

Decryption key must be supplied as one of: :aes-key some-byte-array :password some-string :rsa-privkey some-pkcs8-byte-array

Decrypt ciphertext using one of the provided keys.

`ciphertext` parameter is a cryptopack in the form of either:
- a map
- a string (compacted and JSON-encoded)
- a byte array (compacted and messagepack-encoded)

Decryption key must be supplied as one of:
:aes-key some-byte-array
:password some-string
:rsa-privkey some-pkcs8-byte-array
sourceraw docstring

encryptclj/s

(encrypt plaintext
         &
         {:keys [aes-key password rsa-pubkey output padding enc-key-size]
          :or {output :map padding nil enc-key-size 128}})

Encrypts plaintext with a random data encryption key. DEK is protected with each of the provided key encryption keys and stored in slots in the output.

plaintext parameter may be either a byte array, or a string, which will be treated as UTF-8 bytes.

The following key types are supported, as either scalar values or vectors:

  • :aes-key takes one or more byte arrays of length 16, 24, or 32
  • :password takes one or more strings
  • :rsa-pubkey takes one or more byte arrays of SPKI format RSA public keys

The following additional options are supported:

  • :output must be one of :json, :msgpack, or :map (default)
  • :padding may be a number between 1 and 255 for PKCS#7 padding of plaintext

Basic example:

(def password "A strong password") (encrypt "Attack at dawn" :password password)

Advanced example:

(def backup-key (rand-bytes 16)) (encrypt "hello world" :password ["foo" "bar"] :aes-key backup-key :output :msgpack :padding 16)

Encrypts plaintext with a random data encryption key.
DEK is protected with each of the provided key encryption keys
and stored in slots in the output.

`plaintext` parameter may be either a byte array, or a string,
which will be treated as UTF-8 bytes.

The following key types are supported, as either scalar values or vectors:
- :aes-key takes one or more byte arrays of length 16, 24, or 32
- :password takes one or more strings
- :rsa-pubkey takes one or more byte arrays of SPKI format RSA public keys

The following additional options are supported:
- :output must be one of :json, :msgpack, or :map (default)
- :padding may be a number between 1 and 255 for PKCS#7 padding of plaintext

Basic example:

(def password "A strong password")
(encrypt "Attack at dawn" :password password)

Advanced example:

(def backup-key (rand-bytes 16))
(encrypt "hello world"
         :password ["foo" "bar"]
         :aes-key backup-key
         :output :msgpack
         :padding 16)
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close