GithubHelp home page GithubHelp logo

artkay / ex_aws_s3_crypto Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bmuller/ex_aws_s3_crypto

0.0 0.0 0.0 53 KB

AWS S3 client-side encryption support for Elixir

Home Page: https://hex.pm/packages/ex_aws_s3_crypto

License: MIT License

Go 4.48% Elixir 95.52%

ex_aws_s3_crypto's Introduction

ExAws.S3.Crypto

Build Status Hex pm API Docs

ExAws.S3.Crypto provides client-side encryption support for Amazon S3. It allows you to encrypt data before sending it to S3. This particular implementation currently supports a AWS KMS-managed customer master key and assumes you have one already generated.

ExAws.S3.Crypto makes heavy use of the existing ex_aws_s3 library and Erlang's crypto module. It has confirmed compatability with the Golang AWS SDK client-encryption library and uses AES GCM with 256-bit keys by default.

Note: As of version 2.0, OTP version 22 or greater is required due to changes in the :crypto library.

Installation

To install ExAws.S3.Crypto, just add an entry to your mix.exs:

def deps do
  [
    {:ex_aws_s3_crypto, "~> 3.0"}
  ]
end

(Check Hex to make sure you're using an up-to-date version number.)

Usage

First, make sure you have the id for your master key (should be of the form of a UUID, like 123e4567-e89b-12d3-a456-426655440000) and the bucket you're using already set up. You should be able to make requests using ExAws (see the ExAws docs for configuration instructions).

To encrypt and upload an object, it's easy as pie.

bucket = "my-awesome-bucket"
key_id = "123e4567-e89b-12d3-a456-426655440000"
contents = "this is some special text that should be secret"

# Encrypt, then upload object
request = ExAws.S3.put_object(bucket, "secret.txt.enc", contents)
{:ok, encrypted_request} = ExAws.S3.Crypto.encrypt(request, key_id)
ExAws.request(encrypted_request)

# Or, use this shorter version of above
ExAws.S3.Crypto.put_encrypted_object(bucket, "secret.txt.enc", contents, key_id)

Decrypting is easy too, and doesn't even require knowing the original key id.

# get encrypted object, then decrypt
{:ok, encrypted} = ExAws.S3.get_object(bucket, "secret.txt.enc") |> ExAws.request
{:ok, decrypted} = ExAws.S3.Crypto.decrypt(encrypted)
IO.puts decrypted.body

# Or, use this shorter version of above
{:ok, decrypted} = ExAws.S3.Crypto.get_encrypted_object(bucket, "secret.txt.enc")
IO.puts decrypted.body

See the docs for more examples.

Running Tests

To run tests:

$ mix test

Reporting Issues

Please report all issues on github.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.