This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <string.h> | |
| #include <stdbool.h> | |
| bool isPasswordOK(void) { | |
| char Password[12]; | |
| gets(Password); | |
| return 0 == strcmp(Password, "goodpass"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from fractions import gcd | |
| import random | |
| # Find least common multiplier | |
| def lcm(a, b): | |
| return (a * b) // gcd(a, b) | |
| # Find modular inverse of a with modulo m | |
| def modInverse(a, m): | |
| x = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from Crypto.Util.number import * | |
| p = getStrongPrime(512) | |
| a = getRandomRange(2, p-2) | |
| print GCD(a, p-1) | |
| #loop until you get a GCD of 1 with p-1 | |
| base = 2 | |
| A = pow(base, a, p) | |
| print p, base, A |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import binascii, hashlib | |
| k = "secretkey" | |
| msg = "forge this punks" | |
| kplus = k + "\x00"*(64-len(k)) | |
| ipad = "\x36"*64 | |
| opad = "\x5C"*64 | |
| def XOR(raw1, raw2): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from hashlib import md5 | |
| from base64 import b64decode | |
| from base64 import b64encode | |
| from Crypto import Random | |
| from Crypto.Cipher import AES | |
| # Padding for the input string --not | |
| # related to encryption itself. | |
| BLOCK_SIZE = 16 # Bytes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import matplotlib.image as img | |
| from Crypto.Cipher import AES | |
| from Crypto import Random | |
| #Get the image | |
| kyle = img.imread('kyle.png') | |
| #Before encryption |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import matplotlib.image as img | |
| from Crypto.Cipher import AES | |
| from Crypto import Random | |
| #Get the image | |
| kyle = img.imread('kyle.png') | |
| #Before encryption |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urllib2, random | |
| response = urllib2.urlopen("http://vip.udel.edu/crypto/mobydick.txt") | |
| mobytext = response.read() | |
| onlyletters = filter(lambda x: x.isalpha(), mobytext) | |
| loweronly = onlyletters.lower() | |
| def shiftBy(c, n): | |
| return chr(((ord(c) - ord('a') + n) % 26) + ord('a')) |