Skip to content

Commit

Permalink
readms
Browse files Browse the repository at this point in the history
  • Loading branch information
bt3gl committed Nov 20, 2014
1 parent d8c1966 commit 800cbd2
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
34 changes: 32 additions & 2 deletions Cryptography/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Cryptography

* Often data is just encoded in base64 or hex. Other thimes it's just compressed (gzip).
* Often data is just encoded in base64 or hex. Other times it's just compressed (gzip):
- text 32 characters long --> md5 hash.
- 40 characters long --> SHA1 hash.
- equal signs spread --> base64 encoded string.
- text only letters, without numbers or special characters --> Caesar, Vigenere, or other type of cipher.
- hints about keys and signing --> likely RSA.



Expand All @@ -9,6 +14,8 @@

- The MD5 hashing algorithm always returns 128 bit values, so the chance that two randomly chosen objects have the same hash is 1:2**128.



### Scripts

- Hash length extension attack
Expand All @@ -29,15 +36,19 @@ $ echo -n password | md5sum

- Use Python's md5.md5().digest()

- md5 hashes: [here](http:https://hash-killer.com/) and [here](http:https://www.md5this.com/)
- md5 hashes: [here](http:https://hash-killer.com/), [here](http:https://www.md5this.com/), [here](http:https://www.hashkiller.co.uk/).

- [md5sum](http:https://linux.about.com/library/cmd/blcmdl1_md5sum.htm)
- [md5 creator](http:https://www.md5-creator.com/)

------

## SHA

- SHA-1 has output size of 160 bits, so chances of collisions are 2**160.

- [Hash maker](http:https://ratfactor.com/sha1).

### Scripts
- SHA-256 brute force

Expand Down Expand Up @@ -73,6 +84,10 @@ for a, b, c, d, e, f in itertools.product(ch, ch, ch, ch, ch, ch):

- Frequency analysis: [here](http:https://www.simonsingh.net/The_Black_Chamber/hintsandtips.html) and [here](http:https://www.xarg.org/tools/caesar-cipher)

- [Cesar Cipher decryption](http:https://www.xarg.org/tools/caesar-cipher/) and [here](http:https://tools.zenverse.net/caesar-cipher/).

- [Vigenere Cipher breaker](http:https://www.mygeocachingprofile.com/codebreaker.vigenerecipher.aspx) and [here](http:https://smurfoncrack.com/pygenere/index.php).

### In the command line

```sh
Expand All @@ -88,6 +103,20 @@ In Python [we can use decoding](https://docs.python.org/2/library/codecs.html#co
```python
"YRIRY GJB CNFFJBEQ EBGGRA".decode(encoding="ROT13")
```

### Readings:

- [How Viginere works](http:https://sharkysoft.com/vigenere/).

---

## RSA

* Public-key cryptosystem which uses a public-private key pair to encrypt and decrypt information securely

* [RSA Python](https://pypi.python.org/pypi/rsa)


----

## Pailier Cryptosystem
Expand All @@ -99,6 +128,7 @@ In Python [we can use decoding](https://docs.python.org/2/library/codecs.html#co

---


## Tools

### Scripts
Expand Down
27 changes: 27 additions & 0 deletions Cryptography/Rotation-Ciphers/caesarCipher_from_net.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
def caesar(plaintext,shift):

alphabet=["a","b","c","d","e","f","g","h","i","j","k","l",
"m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

#Create our substitution dictionary
dic={}
for i in range(0,len(alphabet)):
dic[alphabet[i]]=alphabet[(i+shift)%len(alphabet)]

#Convert each letter of plaintext to the corrsponding
#encrypted letter in our dictionary creating the cryptext
ciphertext=""
for l in plaintext.lower():
if l in dic:
l=dic[l]
ciphertext+=l

return ciphertext

#Example useage
plaintext="the cat sat on the mat"
print "Plaintext:", plaintext
print "Cipertext:",caesar(plaintext,3)
#This will result in:
#Plaintext: the cat sat on the mat
#Cipertext: wkh fdw vdw rq wkh pdw

0 comments on commit 800cbd2

Please sign in to comment.