## Caesar Cipher

Caesar Cipher-encryption just involves shifting each alphabetic letter by some number.
Automatically guess shift number: https://www.xarg.org/tools/caesar-cipher/
Print all shifts: caesar_all.py

## Substitution Cipher

Substitution ciphers substitute each letter with another letter. They can be cracked by frequency analysis.
Guess cipher: http://quipqiup.com/index.php
View n-grams to help guess letters: subst.py and https://ehsandev.com/pico2014/cryptography/substitution.html

## Block Ciphers

Simple XOR CBC key finding script: bricks_of_gold_csaw_2015.py

## RSA

### Setup

Use this script to install a few useful utilities for working with RSA problems. You will need git, python, pip, and virtualenv already installed on your system.
install_rsa.sh

### General RSA Attack Notes

1. Small public modulus n - use https://factordb.com/index.php to find p and q.
2. Given multiple keys - see if any of the keys have common factors using the Euclidean Algorithm.
1. p and q are close to each other - use YAFU or https://www.alpertron.com.ar/ECM.HTM
2. Two ciphertexts use the same modulus n but different exponents e - use: same_modulus.py
3. Small p or q - use YAFU or https://www.alpertron.com.ar/ECM.HTM
4. Large e or d - Wiener’s attack. Use attackrsa tool.
5. Same m and e for multiple messages - Hastad’s Broadcast Attack. Use attackrsa tool.
6. If num_ciphertexts >= e then you can use Chinese Remainder Theorem to calculate the message (but gcd of all n’s must be 1 - if the gcd between any two n’s is not 1, then you can just find a common factor between them).
7. If c < n, just take the eth root of c to get the plaintext.

### Basic RSA Decryption

If you can easily find p and q or d, then you can use this script to decrypt a ciphertext to ASCII.
decrypt_rsa.py

### Commands

Here are some commands to transform and work with keys.