Skip to content

Commit

Permalink
Deterministic stream example
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Cieplak committed Apr 3, 2016
1 parent 1f04142 commit 8f3af07
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,35 @@ yorke xor <(echo "secret message") <(cat /dev/urandom | tee key.txt) > cipher.tx
yorke xor cipher.txt key.txt
```

Encrypt a message with a deterministic, pseudo-random stream:

```bash
yorke xor <(echo "secret message") <(yorke sha256 `uuidgen | tee key.iv`) > cipher.txt
yorke xor cipher.txt <(yorke sha256 `cat key.iv`) | xxd
```

WARNING: Never re-use the same initialization vector! It is feasible to recover
the initialization vector by XOR'ing two ciphertexts generated against the
common stream. Observe the following:

```bash
yorke xor <(echo "SSN: 512-73-5461") <(yorke sha256 `uuidgen | tee key.iv`) > cipher1.txt
yorke xor <(echo "SSN: 389-16-2734") <(yorke sha256 `cat key.iv`) > cipher2.txt

xxd cipher1.txt
0000000: 641a c768 a61c 4d2e dd58 abd9 ad05 451c d..h..M..X....E.
0000010: 17 .

xxd cipher2.txt
0000000: 641a c768 a61a 4425 dd5e aed9 aa06 4019 d..h..D%.^....@.
0000010: 17 .

yorke xor cipher1.txt cipher2.txt | xxd
0000000: 0000 0000 0006 090b 0006 0500 0703 0505 ................
0000010: 00

```

# Installation

```bash
Expand Down

0 comments on commit 8f3af07

Please sign in to comment.