Skip to content

OpenSSL and Erlang crypto bindings in Elixir, a crypto library with ease of use in mind

License

Notifications You must be signed in to change notification settings

elefthei/krypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Krypto

Crypto library in Elixir, using Erlang public_key and OpenSSL ports

Installation

The package can be installed as:

  1. Add krypto to your list of dependencies in mix.exs:
def deps do
    [{:krypto, "~> 0.1.4"}]
end
  1. Ensure krypto is started before your application:
def application do
    [applications: [:krypto]]
end

Overview

Krypto is an opinionated, light-weight crypto implementation for Elixir with native OpenSSL bindings.

Example

You can use krypto in your Elixir application to do the following:

  1. Generate an RSA key pair (in DER format):
{ publicKey, privateKey } = Krypto.RSA.getKeypair()
  1. Encrypt using the public key:
encrypted_secret = Krypto.RSA.encrypt("Super secret message", publicKey)
  1. Decrypt using the private key:
decrypted_secret = Krypto.RSA.decrypt(encrypted_secret, privateKey)
  1. Sign a message:
message = "This message should be signed",
signature = Krypto.RSA.sign(message, privateKey)
if Krypto.RSA.verify(message, signatre, publicKey) do
    IO.puts "This signature matches!"
end
  1. Get message digests:
hash_md5 = Krypto.Hash.md5("Hash me in md5!")
hash_sha224 = Krypto.Hash.sha224("Hash me in sha224!")
hash_sha256 = Krypto.Hash.sha256("Hash me in sha256 (our prefered one)!")
hash_sha384 = Krypto.Hash.sha384("Hash me in sha384!")

About

OpenSSL and Erlang crypto bindings in Elixir, a crypto library with ease of use in mind

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages