->key ^
idempotent function converting input into a key
(-> {:type "AES",
:mode :secret,
:format "RAW",
:encoded "euHlt5sHWhRpbKZHjrwrrQ=="}
(->key)
(->key))
=> java.security.Key
decrypt ^
decrypts a byte array using a key
(-> (decrypt (encode/from-hex "30491ab4427e45909f3d2f5d600b0f93")
{:type "AES",
:mode :secret,
:format "RAW",
:encoded "euHlt5sHWhRpbKZHjrwrrQ=="})
(String.))
=> "hello world"
encrypt ^
encrypts a byte array using a key
(-> (encrypt (.getBytes "hello world")
{:type "AES",
:mode :secret,
:format "RAW",
:encoded "euHlt5sHWhRpbKZHjrwrrQ=="})
(encode/to-hex))
=> "30491ab4427e45909f3d2f5d600b0f93"
generate-key ^
generates a key according to algorithm
(generate-key)
=> ("AES" "ARCFOUR" "Blowfish" "DES" "DESede"
"HmacMD5" "HmacSHA1" "HmacSHA224" "HmacSHA256"
"HmacSHA384" "HmacSHA512" ...)
(generate-key "AES" {:length 128})
;;=> #key {:type "AES",
;; :mode :secret,
;; :format "RAW",
;; :encoded "AQgv8l+vJNfnEWuhHs55wg=="}
(generate-key "HmacSHA224" {:length 40})
;;=> #key {:type "HmacSHA224",
;; :mode :secret,
;; :format "RAW",
;; :encoded "0qQkmic="}
generate-key-pair ^
creates a public and private key pair
(generate-key-pair)
=> ("DSA" "DiffieHellman" "EC" "RSA")
(generate-key-pair "RSA" {:length 512})
;;=> [#key {:type "RSA",
;; :mode :public,
;; :format "X.509",
;; :encoded "...." }
;; #key {:type "RSA",
;; :mode :private,
;; :format "PKCS#8",
;; :encoded "..."}]
key->map ^
returns a map representation of a key
(key->map (generate-key "AES" {:length 128}))
=> (contains {:type "AES",
:mode :secret,
:format "RAW",
:encoded string?})