This commit is contained in:
bt3gl 2014-11-20 16:18:22 -05:00
parent d8c1966631
commit 800cbd2a97
2 changed files with 59 additions and 2 deletions

View File

@ -1,6 +1,11 @@
# Cryptography # 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.
@ -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. - 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 ### Scripts
- Hash length extension attack - Hash length extension attack
@ -29,8 +36,10 @@ $ echo -n password | md5sum
- Use Python's md5.md5().digest() - Use Python's md5.md5().digest()
- md5 hashes: [here](http://hash-killer.com/) and [here](http://www.md5this.com/) - md5 hashes: [here](http://hash-killer.com/), [here](http://www.md5this.com/), [here](http://www.hashkiller.co.uk/).
- [md5sum](http://linux.about.com/library/cmd/blcmdl1_md5sum.htm)
- [md5 creator](http://www.md5-creator.com/)
------ ------
@ -38,6 +47,8 @@ $ echo -n password | md5sum
- SHA-1 has output size of 160 bits, so chances of collisions are 2**160. - SHA-1 has output size of 160 bits, so chances of collisions are 2**160.
- [Hash maker](http://ratfactor.com/sha1).
### Scripts ### Scripts
- SHA-256 brute force - SHA-256 brute force
@ -73,6 +84,10 @@ for a, b, c, d, e, f in itertools.product(ch, ch, ch, ch, ch, ch):
- Frequency analysis: [here](http://www.simonsingh.net/The_Black_Chamber/hintsandtips.html) and [here](http://www.xarg.org/tools/caesar-cipher) - Frequency analysis: [here](http://www.simonsingh.net/The_Black_Chamber/hintsandtips.html) and [here](http://www.xarg.org/tools/caesar-cipher)
- [Cesar Cipher decryption](http://www.xarg.org/tools/caesar-cipher/) and [here](http://tools.zenverse.net/caesar-cipher/).
- [Vigenere Cipher breaker](http://www.mygeocachingprofile.com/codebreaker.vigenerecipher.aspx) and [here](http://smurfoncrack.com/pygenere/index.php).
### In the command line ### In the command line
```sh ```sh
@ -88,6 +103,20 @@ In Python [we can use decoding](https://docs.python.org/2/library/codecs.html#co
```python ```python
"YRIRY GJB CNFFJBEQ EBGGRA".decode(encoding="ROT13") "YRIRY GJB CNFFJBEQ EBGGRA".decode(encoding="ROT13")
``` ```
### Readings:
- [How Viginere works](http://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 ## Pailier Cryptosystem
@ -99,6 +128,7 @@ In Python [we can use decoding](https://docs.python.org/2/library/codecs.html#co
--- ---
## Tools ## Tools
### Scripts ### Scripts

View File

@ -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