Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/trapped/elixir-rsa
Erlang public_key cryptography wrapper for Elixir
https://github.com/trapped/elixir-rsa
Last synced: 2 months ago
JSON representation
Erlang public_key cryptography wrapper for Elixir
- Host: GitHub
- URL: https://github.com/trapped/elixir-rsa
- Owner: trapped
- License: mit
- Created: 2014-12-24T17:45:10.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-11-21T16:01:27.000Z (about 5 years ago)
- Last Synced: 2024-08-02T02:11:33.523Z (5 months ago)
- Language: Elixir
- Homepage: https://hex.pm/packages/rsa
- Size: 8.79 KB
- Stars: 34
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - `public_key` cryptography wrapper for Elixir. (Cryptography)
- fucking-awesome-elixir - rsa - `public_key` cryptography wrapper for Elixir. (Cryptography)
- awesome-elixir - rsa - `public_key` cryptography wrapper for Elixir. (Cryptography)
README
Easy RSA encryption/decryption in Elixir
========================================This module wraps Erlang's `public_key` module, making RSA encryption/decryption a trivial task.
```elixir
# Decode your public and private keys
public_key = RSA.decode_key "-----BEGIN RSA PUBLIC KEY----- ..."
private_key = ...# Encrypt a string using the public key and decrypt it using the private key
plaintext = "hello world"
cyphertext = plaintext |> RSA.encrypt {:public, public_key}
# << ... encrypted binary data ... >>
# Encode it to base64
encrypted_b64 = :base64.encode_to_string cyphertext
# "... base64 ASCII text ..."# Decode a base64 encrypted string and decrypt it
cyphertext = :base64.decode encrypted_b64
plaintext = cyphertext |> RSA.decrypt {:private, private_key}
# "hello world"
```