Rainbow tables as a solution to large prime factoring

From one of my favorite books ever, Applied Cryptography by Bruce Schneier “If someone created a database of all primes, won’t he be able to use that database to break public-key algorithms? Yes, but he can’t do it. If you could store one gigabyte of information on a drive weighing one gram, then a list … Read more

How does the man in the middle attack work in Diffie–Hellman?

I think you’re confusing the basic Diffie-Hellman, which is a key exchange protocol, with the ‘authenticated version’ which uses a certificate authority (CA). Nice explanation of how the basic Diffie-Hellman is vulnerable to man-in-the-middle from RSA Labs. “The Diffie-Hellman key exchange is vulnerable to a man-in-the-middle attack. In this attack, an opponent Carol intercepts Alice’s … 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

How to use public and private key encryption technique in C#

Code example: private static string _privateKey; private static string _publicKey; private static UnicodeEncoding _encoder = new UnicodeEncoding(); private static void RSA() { var rsa = new RSACryptoServiceProvider(); _privateKey = rsa.ToXmlString(true); _publicKey = rsa.ToXmlString(false); var text = “Test1”; Console.WriteLine(“RSA // Text to encrypt: ” + text); var enc = Encrypt(text); Console.WriteLine(“RSA // Encrypted Text: ” + … Read more