Posts

Showing posts from June, 2024

Asymmetric encryption in Ruby On Rails OR Private Public key encryption

  First we need to generate a key pair. This creates two keys, a public key which will only be used to encrypt data, and a private key, which will only be used to decrypt data. The private key is protected by a password know only to us. When it comes to choosing strong passwords, I suggest using   Diceware .   2048   is the key size in bits. Bigger is better, but also slower; 2048 is considered a good trade off between speed and encryption strength. We are also limited by this to encrypting as most 2048 bits, more on this below. % openssl genrsa -des3 -out private.pem 2048 Generating RSA private key, 2048 bit long modulus ......+++ .+++ e is 65537 (0x10001) Enter pass phrase for private.pem: Verifying - Enter pass phrase for private.pem: Then we extract the public key: openssl rsa -in private.pem -out public.pem -outform PEM -pubout Enter pass phrase for private.pem: writing RSA key Once we have the keys, we can encrypt data using the following: #!/usr/bin/env ruby require 'open

Installing nio4r on macOS

  bundle config --local build.nio4r --with-cflags="-Wno-error=implicit-function-declaration -Wno-error=incompatible-function-pointer-types"