Using the ‘with’ statement for custom python objects to manage resources.

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 with statement

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.

What is a Context Manager?

From the Python documentation:

A context manager is an object that defines the runtime context to be established when executing a with statement. The…


Creating the Elixir Project

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.

Create Elixir Project

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.

Project Dependencies
Since we are working with security stuff, we will need a cryptographic library. We will useenacl (pronounced Na-Cl). …


Sharing user-encrypted data using public-private key pairs

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…


In Part I, we looked at how we’ll design a per-user encryption system. With the idea from Part I, let’s create our Phoenix project and see how we can accomplish per-user encryption.

Creating a phoenix project

$ mix phx.new user_encryption

Libsodium

Cryptography is hard and it’s definitely not a good idea to roll your own library when doing crypto in your project. It’s better to use a tried and tested solution. In this project, we’ll use Libsodium. As described on its project page

Sodium is a new, easy-to-use software library for encryption, decryption, signatures, password hashing and more.

It is a portable, cross-compilable, installable, packageable…


Using passwords to encrypt user data

One of the projects I’m working on has one important feature — the privacy of users’ data. Basically, the ability for users to secure their data so that only that user can access the data. Even in case of a hack, the hacker should not be able to have access to the user’s data. This means all such data stored on the server must be encrypted and decrypted only when the user wants to access that data. In that case, all that the hacker will have is encrypted data.

In this 2-part post, we will explore how to encrypt user…


Asynchronous communication

Important: Read Part I of this post before continuing.

In Part I, we looked at how to call Python functions from Elixir using Erlport!

ErlPort is an Elixir library which makes it easier to connect Erlang to a number of other programming languages using the Erlang port protocol.

However, as you may have noticed, the calling process had to wait for Python to finish processing and return the results. This works for operations that are instant and doesn’t take much time. Otherwise, it’s not much fun when you are running an intensive Python function. …


Generating and Decoding QRCodes using Python modules from Elixir app

The Erlang VM, on which Elixir runs, is efficient for applications in particular domains but falls short when it comes to other operations like data processing and computation-heavy stuff. Python on the other hand, has a rich set of packages for tackling data processing and scientific calculations.

Luckily the Erlang VM allows interoperability with other languages using the Erlang port protocol.

ErlPort is a library for Elixir which makes it easier to connect Erlang to a number of other programming languages using the Erlang port protocol. …


UI testing is useful for apps with complex UI states especially where different users are involved in completing a task. For instance, in a patient management system, an x-ray technician cannot take x-ray of a patient before the patient has been given the right injections by a nurse. Manually testing UI interactions for such apps is not only time consuming but also difficult to maintain multiple sessions for the users involved.

So with our current project MedTrack, a platform that simplifies the operations of diagnostic/scan centers and coordinates hospitals with diagnostic and scan centers, I wanted to extensively test the…


Erlang erlang erlang erlang …

I got nodes and a clusters,
Processes working like minions,
So cheap, I can start a million

Real-time, Erlang!
Messaging, Erlang!
Scalable, Erlang!

Fault-tolerant, no need to catch,
Fault-tolerant, I just let it crash
Mnesia, handy
Hot-swap, candy

Concurrency, Erlang!
RPC, Erlang!
Clusters, Erlang!

https://www.youtube.com/watch?v=lsJLLEwUYZM


How we cut SMS costs using Twitter Digits

Important Update:

Badu

Software Engineer Python, Elixir/Erlang, NLP https://baduboahen.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store