-
Notifications
You must be signed in to change notification settings - Fork 113
How to Encrypt/Decrypt Sensitive Data in Elixir? #80
Copy link
Copy link
Closed
Labels
T1dTime Estimate 1 DayTime Estimate 1 DayenhancementNew feature or enhancement of existing functionalityNew feature or enhancement of existing functionalitypriority-2Second highest priority, should be worked on as soon as the Priority-1 issues are finishedSecond highest priority, should be worked on as soon as the Priority-1 issues are finishedquestionA question needs to be answered before progress can be made on this issueA question needs to be answered before progress can be made on this issue
Description
Scenario
We want to encrypt (personal) data before storing it in PostgreSQL.
So that if for any reason the DB is ever "compromised" through SQL injection or other "attack",
the data is strongly encrypted and thus the "leak" is (somewhat) "mitigated".
read: https://security.stackexchange.com/questions/56278/field-level-encryption-vs-disk-encryption-for-pci-compliance
The starting point is to read the Erlang crypto docs: http://erlang.org/doc/man/crypto.html
It has lots of detail but few practical examples ...
Requirement
- Use Symmetric Key Encryption
- Determine additional CPU/Memory load impact from encrypting individual fields vs. entire record.
We read: https://github.com/rubencaro/cipher which is "overkill" for what we need.
Example code:
# encryption key
key = :crypto.hash(:sha256, "get key from aws parameter store") |> Base.encode16
# initialisation vector
iv = "clave2 con chicha" |> String.slice(0,16)
# data
data = "Hello World!"
IO.puts "data (before encryption): " <> data
# encrypt:
encrypted = :crypto.aes_cbc_128_encrypt key, iv, data
IO.puts "encrypted: " <> encrypted
Looked at: https://github.com/danielberkompas/cloak
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
T1dTime Estimate 1 DayTime Estimate 1 DayenhancementNew feature or enhancement of existing functionalityNew feature or enhancement of existing functionalitypriority-2Second highest priority, should be worked on as soon as the Priority-1 issues are finishedSecond highest priority, should be worked on as soon as the Priority-1 issues are finishedquestionA question needs to be answered before progress can be made on this issueA question needs to be answered before progress can be made on this issue