Teach yourself Public Key Cryptography in 5 seconds – Cypherpunk 1

When I taught myself cryptography, I felt like an idiot for months. Either I was too stupid to get it, or the subject was made complex to such a degree that only a PhD in abstract math could get it. After a while I finally “got it”, to the point where I now feel I’m a fully autodidact Cypherpunk. Hence, I feel obliged to not only teaching it to you, but also provide tools that are simple to use, such that you can get started with it yourself in some few seconds. Below is a video you can watch, and I guarantee you that you’ll understand mostly everything you’ll ever need to understand in this subject, in order to become a complete “Cypherpunk”.

Creating an RSA key with Magic is as simple as follows. However, you might want to watch the above video first, and also download Magic in order to follow the rest of the code examples.

Then using the public key to encrypt a message, can be done with the following code.

Decrypting the above message with the private key can be done as follows.

And voila, you have a cryptographically secured channel for communication. In a real world scenario, you’ll probably want to use a higher bit strength than the default of 1024 that Magic is using, which you can override using the [strength] argument as you generate your key pair. However, I go through most of these things in the video, and also at the following documentation for the crypto slots of Magic.

Kids, do this at home!

This UrIoTNews article is syndicated fromDzone