Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
bool isPasswordOK(void) {
char Password[12];
gets(Password);
return 0 == strcmp(Password, "goodpass");
}
@uz214
uz214 / rsa-encryption.py
Created March 22, 2018 01:10 — forked from asBrettisay/rsa-encryption.py
This shows how rsa encryption is done
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
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
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):
@uz214
uz214 / phyton
Created March 16, 2018 16:08
AES-CBC-encryption and decryption PNG-image-crypto
from Crypto.Cipher import AES
from PIL import Image
import base64
import os
import sys
IV_LEN = 16
BLOCK_LEN = 16
@uz214
uz214 / aes-cbc.py
Created March 15, 2018 04:56 — forked from lopes/aes-cbc.py
Simple Python example of AES in CBC mode.
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
@uz214
uz214 / python
Created March 15, 2018 04:43
Encrypting the Image in CBC Mode AES
from Crypto.Cipher import AES
key = "uzairisawesome14"
iv = "0987654321098765"
cipher = AES.new(key, AES.MODE_CBC, iv)
#cipher = AES.new(key)
#print (key)
with open("tux.bmp", "rb") as f:
clear = f.read()
#ciphertext = cipher.encrypt(clear)
clear_trimmed = clear[64:-2]
@uz214
uz214 / python
Created March 14, 2018 20:25
AES Image encryption EBC
from Crypto.Cipher import AES
key = "uzairisawesome14"
cipher = AES.new(key)
#print (key)
with open("tux.bmp", "rb") as f:
clear = f.read()
#ciphertext = cipher.encrypt(clear)
clear_trimmed = clear[64:-2]
ciphertext = cipher.encrypt(clear_trimmed)
ciphertext = clear[0:64] + ciphertext + clear[-2:]
@uz214
uz214 / ecb_vs_cbc.py
Created March 14, 2018 06:23 — forked from seljukgulcan/ecb_vs_cbc.py
Python CBC - ECB on Image
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
@uz214
uz214 / ecb_vs_cbc.py
Created March 14, 2018 06:23 — forked from seljukgulcan/ecb_vs_cbc.py
Python CBC - ECB on Image
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