How to encrypt and decrypt something with AWS KMS

This going to be a little more technical. Basically I am documenting a problem I was trying to research for myself. It is a very basic intro do encrypting and decrypting a file using AWS KMS.

Image for post
Image for post

Encrypt

Let’s start with a single file we want to encrypt.

echo ‘Hello, Olivier’ > message.txt

Now we are ready to encrypt this message. I will assume that you already created a KMS key and have an ARN for said key. The command ( aws kms encrypt ) takes two mandatory arguments plaintext and key_id.

aws kms encrypt --plaintext file://message.txt --key-id arn:aws:kms:us-east-1:xxxxxxxx:key/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx

This will return something like…


Image for post
Image for post
Illustrations by Tim Peacock

Like many technology organizations, Customer Care Technology, my team at The New York Times, uses scrum as our main process. To plan our sprints, we would go through the backlog, pick stories and assign a story to each of our six engineers, who would then work hard to get their story done. Because of unforeseen roadblocks, the stories would often get pushed to the next sprint or we would work together on a story to finish it before the end of the sprint. …


Are these really predictions, or merely stuff I intend to really learn this year? Wishful thinking maybe?

Frontend

This is an easy one. React had a meteoric rise in 2017, effectively overtaking Angular as the most popular front-end framework. Will there beanother framework that overtakes React? Looks like Vue.js is the new kid on the block. My prediction: React will continue to be the lingua franca of the front-end. Many developers love React. I just don’t see why developers would leave React in droves.

Backend

A few years ago Node.js made a big splash, but is now plateauing a bit. Ruby on Rails is no longer the coolest kid. Corporate still does Java. Php is still around. Python is gaining popularity, because of machine learning and because it’s fun. And by extension we’re seeing Django getting a new boost. But 2018 is the year of .NET’s explosion. Microsoft open sourced its framework a few years ago. .NET core 2.0 came out last year, and it is cross-platform. Developers are going to realize that it is no longer M$FT but that Satya Nadella really turned the company around. C# is a powerful language, there is a huge eco-system, you don’t have to use Visual Studio, you can do back-end, web, mobile apps, libraries, you can run it on linux or on your mac. …


Until someone explained it to me like this …

Image for post
Image for post

As the title states, JavaScript closures have always been a bit of a mystery to me. I have read multiple articles, I have used closures in my work, sometimes I even used a closure without realizing I was using a closure.

Recently I went to a talk where someone really explained it in a way it finally clicked for me. I’ll try to take this approach to explain closures in this article. Let me give credit to the great folks at CodeSmith and their JavaScript The Hard Parts series.

Before we start

Some concepts are important to grok before you can grok closures. …


I am rolling my own JavaScript promise.

Image for post
Image for post

Sometimes, when you really want to understand something, it’s worth trying to build it yourself. That is what I do with promises in this article. I am trying to build a very basic ‘Promise’.

At first there were callbacks …

Let’s begin with the basics, before anybody heard of promises, we had callbacks. Take a look at the following snippet.

const testUrl = 'https://api.github.com/users/odemeulder'
const fetchData = (url, callback) => {
let xhr = new XMLHttpRequest()
xhr.onreadystatechange = () => {
if (xhr.readyState == 200 ) {
callback(xhr.responseText)
}
}
xhr.open(url)
xhr.send()
}
fetchData(testUrl, response => console.log(response) )

What does it do? It creates a very simple function that takes a url, reads it using the XMLHttpRequest and allows a callback function to do something with the result. And in the last line, we call our new function; as a callback we provide a function that prints out the response. Very simple. If you are not familiar with XMLHttpRequest, don’t fret, it is not important to understand for the rest of the article. Just know that it is the object that the browser provides to JavaScript to perform http requests. It is an asynchronous function, it takes a callback when the onreadystatechange event fires. …


Image for post
Image for post

This post is NOT a post to show you how to use forEach, map, filter and reduce, NOR is it a post showing the benefits of higher order functions. There are plenty of other articles that do that.

When I want to understand a basic concept, I like to try to implement it myself, even if it is a very basic version. People learn in different ways, this works for me. So let me take you on this journey as I try to create my own forEach, map, reduce and filter functions in JavaScript.

myForEach

In order to disambiguate from the built-in forEach, let’s call my new function myForEach. …


Take a Fortune 500 company. Let’s say Apple or Exxon or Walmart. Apple has about 100,000 employees, Walmart over 2 million employees. Such a company must have a bureaucracy, a set of systems and procedures, a reporting structure to make all their employees work in tandem towards a common goal. Ultimately the goal of a corporation is to make money. Generally speaking, the CEO, the other executives and the board lay out a vision to achieve that goal.

A corporation is run by a Chief Executive Officers and other C-level officers that report to him: Chief Financial Officer, Chief Operations Officer, Chief Marketing Officer, Chief Technical Officer. Sometimes, a company is so big, that the corporation is organized around different business units. In that case, each business unit has it’s own CEO, COO, CFO, … It may have different names, but let’s refer to the CEO and all the people that report to him as the Executive Team. …

About

Olivier De Meulder

Software engineering manager NY Times, dad, husband, former startup founder, TaeKwonDo black belt, cook, news & tech junkie. Here are some of my mind ramblings.

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