How to do PGP in Python (generate keys, encrypt/decrypt)

You don’t need PyCrypto or PyMe, fine though those packages may be – you will have all kinds of problems building under Windows. Instead, why not avoid the rabbit-holes and do what I did? Use gnupg 1.4.9. You don’t need to do a full installation on end-user machines – just gpg.exe and iconv.dll from the … Read more

Cracking short RSA keys

Your teacher gave you: Public Key: (10142789312725007, 5) which means n = 10142789312725007 e = 5 where n is the modulus and e is the public exponent. In addition, you’re given Private Key: (10142789312725007, 8114231289041741) meaning that d = 8114231289041741 where d is the decryption exponent that should remain secret. You can “break” RSA by … Read more

Encrypting data with a public key in Node.js

A library is not necessary. Enter crypto. Here’s a janky little module you could use to encrypt/decrypt strings with RSA keys: var crypto = require(“crypto”); var path = require(“path”); var fs = require(“fs”); var encryptStringWithRsaPublicKey = function(toEncrypt, relativeOrAbsolutePathToPublicKey) { var absolutePath = path.resolve(relativeOrAbsolutePathToPublicKey); var publicKey = fs.readFileSync(absolutePath, “utf8”); var buffer = Buffer.from(toEncrypt); var encrypted = … Read more