{{ message }}

Instantly share code, notes, and snippets.

# Michael Cyphermikeecb

Created Apr 18, 2018
Analysis of Comprehension Optimization
View comprehension_optimization_analysis.py
 from optimize_comprehensions import optimize_comprehensions import numpy as np import matplotlib.pyplot as plt import timeit from functools import partial from time import sleep def list_comprehension(expensive_func):
Created Apr 17, 2018
Transforming Python ASTs to Optimize Comprehensions
View optimize_comprehensions.py
 import inspect from ast import comprehension [136/153] from ast import dump from ast import fix_missing_locations from ast import parse from ast import List from ast import Load from ast import DictComp from ast import GeneratorExp from ast import SetComp
Created May 13, 2017
Cryptopals Set 1 Exercise 16
View cryptopals_1_16.py
 from Crypto.Cipher import AES from random import randint def xor(b1, b2): b = bytearray(len(b1)) for i in range(len(b1)): b[i] = b1[i] ^ b2[i] return b def random_key(length):
Created May 13, 2017
Cryptopals Set 2 Exercise 16 Simplified
View cryptopals_1_16_simplified.py
 def crack(): first_block = bytearray('A' * AES.block_size) second_block = bytearray("AadminAtrueA") plaintext = first_block + second_block ciphertext = encryption_oracle(plaintext) # We 'know' the prefix is two blocks long offset = 32
Last active Aug 18, 2020
Oracles
View oracles.py
 key = bytes(random_key(AES.block_size)) iv = bytearray(random_key(AES.block_size)) def encryption_oracle(input_data): input_data = input_data.replace(';','%3b').replace('=','%3d') plaintext = bytearray( "comment1=cooking%20MCs;userdata=" + input_data + ";comment2=%20like%20a%20pound%20of%20bacon" )
Created May 9, 2017
Last active Aug 18, 2020
Cryptopals Challenge Set 2 Exercise 14 Simplified
View cryptopals_1_14_simplified.py
 key = bytes(random_key(16)) random_prefix = random_key(randint(0, 256)) def encryption_oracle(data): unknown_string = bytearray(( "Um9sbGluJyBpbiBteSA1LjAKV2l0aCBteSByYWctdG9wIGRvd24gc28gbXkg\n" + "aGFpciBjYW4gYmxvdwpUaGUgZ2lybGllcyBvbiBzdGFuZGJ5IHdhdmluZyBq\n" + "dXN0IHRvIHNheSBoaQpEaWQgeW91IHN0b3A/IE5vLCBJIGp1c3QgZHJvdmUg\n" + "YnkK" ).decode("base64"))
Created May 9, 2017
Cryptopals Challenge Set 2 Exercise 14 Simplified
View cryptopals_1_14_simplified.py
 from Crypto.Cipher import AES from random import randint from collections import defaultdict def repeated_blocks(buffer, block_length=16): reps = defaultdict(lambda: -1) for i in range(0, len(buffer), block_length): block = bytes(buffer[i:i + block_length]) reps[block] += 1 return sum(reps.values())
Last active Aug 18, 2020
Cryptopals Challenge Set 2 Exercise 14
View cryptopals_1_14.py
 from Crypto.Cipher import AES from random import randint from collections import defaultdict def repeated_blocks(buffer, block_length=16): reps = defaultdict(lambda: -1) for i in range(0, len(buffer), block_length): block = bytes(buffer[i:i + block_length]) reps[block] += 1 return sum(reps.values())
Last active May 8, 2017
Cryptopals Challenge 1 Set 13
View cryptopals_1_13.py
 from Crypto.Cipher import AES from random import randint def aes_128_ecb_enc(buffer, key): obj = AES.new(key, AES.MODE_ECB) return bytearray(obj.encrypt(bytes(buffer))) def aes_128_ecb_dec(buffer, key): obj = AES.new(key, AES.MODE_ECB)
You can’t perform that action at this time.