The Easiest Way to Encrypt in Python

Encrypting data is easy, but securing keys is very difficult. You can skim 6 Questions to Ask Before Encryption Data to get a better sense of the responsibilities that come with encrypting data.

Luckily, we can just use Peacemakr to solve these hard problems.

Peacemakr’s E2E-Encryption Python SDK

Peacemakr provides free E2E-Encryption-as-a-Service through an open-source Python SDK. Of course, it supports other languages too. Under the hood, Peacemakr uses a dedicated SaaS to provide centralized configuration management to make your E2E-Encryption simple and fast.

Peacemakr: The Easiest way to Encrypt in Python

#1 Install Dependencies

Since the Peacemakr SDKs are open-source, you may download from the source directly on GitHub. Otherwise, just

$ pip install peacemakr

#2 Get a Peacemakr APIKey

E2E-Encryption requires access to the SaaS. They have a demo APIKey to try it,

export PEACEMAKR_APIKEY=d1Maw58P2xCQ8d0GV15n22SQNI6lYXHzWLCTEvNPHnY=

When you’re ready to use your own keys, just register for a free account at https://peacemakr.io,

#3 Register your Client

Before we encrypt data, we need to register a Peacemakr Client. Registering allows encryption keys to be delivered to your client. Registration requires an APIKey, client name, host, and a persister. For example,

import peacemakr as p
import peacemakr.factory as factory
api_key = "my-api-key-from-step-2-above"
persister = p.InMemoryPersister()
sdk = factory.get_crypto_sdk(api_key=api_key,
client_name="hello world",
peacemakr_hostname="https://api.peacemakr.io",
persister=persister
)
sdk.register()

#4 Finally, Encrypt your Data

Transform your data into a serialized binary format, and use peacemakr to encrypt it. When you’re ready to operate on your data again, decrypt it.

import osrandom_bytes = os.urandom(100)
encrypted_bytes = sdk.encrypt(random_bytes)
...decrypted_bytes = sdk.decrypt(encrypted_bytes)

It’s really that simple. You can read up on what is happening under the hood directly in our open source SDKs, on our website.

--

--

--

Ex-Apple, Director of Security Architecture at Robinhood. Lives in San Francisco. Plant-based Health Nut, Podcaster, Motorcycle Rider, Runner, and Biker

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Deployment Automation with Jenkins, Docker, GitHub and Git

Axial Monitoring System through Gyroscope Sensor (I2C Device) using Node-Red

Joystream. About the roles in the project and who you can become.

Explaining Code With Art & p5js

AutoLISP routine to Tabulate Circles in an AutoCAD Drawing

Line Follower Control Circuit for Robots

Maintaining distance using Ultrasonic sensor with Arduino

The rise of Declarative UI patterns

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
Jon McLachlan

Jon McLachlan

Ex-Apple, Director of Security Architecture at Robinhood. Lives in San Francisco. Plant-based Health Nut, Podcaster, Motorcycle Rider, Runner, and Biker

More from Medium

Build a WORDLE bot using python [part — 2]

Python : Decorator and Generator

Windows Python Developers Had Better Setup Earlier (II): Add Anaconda Prompt on Windows Terminal

Python Decorators That are More Than Decorative