If you’ve used python for a while you are familiar with the
with statement, especially for reading and writing files. Using the
with statement guarantees that the file will be closed even if an error occurs while executing the block of code inside the
This is kind of similar to using
try... except... finally construct, except it's more cleaner and provides a more powerful abstraction.
In Python, this is achieved through a context manager.
A context manager is an object that defines the runtime context to be established when executing a with statement. The context manager handles the entry into, and the exit from, the desired runtime context for the execution of the block of code. Context managers are normally invoked using the with statement (described in section The with statement), but can also be used by directly invoking their methods.
Typical uses of context managers include saving and restoring various kinds of global state, locking and unlocking resources, closing opened files, etc. …
In the previous post, we discussed the design of how to share and update encrypted documents with multiple users. In this post, we will create an Elixir project based on those ideas.
Let’s start by creating a new elixir project using
mix new command
$ mix new user_encryption
This will create a new elixir project for us.
This is the follow up to a series of posts on securing sensitive user data using encryption. The first two posts explored how to encrypt user data using symmetric encryption by using user tokens such as a password or a PIN.
In this post, we will explore
1) Securing user data using public-private keys (asymmetric encryption)
2) Allow users to securely share encrypted data with other users
3) Allowing multiple users to securely modify a shared encrypted data
Using symmetric encryption work for simple scenarios where data sharing is not required. However, it becomes a challenge when a user wants to share encrypted data with other users. Better still, allowing multiple users to edit the same encrypted document. The challenge is that by using symmetric encryption, data is encrypted with a single key and can only be decrypted with the same key. Since our per-user encryption implementation is using a password-derived key to encrypt a user’s data, we can’t use symmetric encryption as we will have to know the user’s password or PIN for other users to access or make changes to data encrypted by that user. …