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
| Decryption | |
| def read_key(key_file) | |
| File.read(key_file).split(',').map { |x| x.to_i }.pack('c*') | |
| end | |
| des = OpenSSL::Cipher::Cipher.new('des-ede3') | |
| des.decrypt | |
| des.key = read_key('key.bin') | |
| result = des.update(decoded) + des.final |
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
| # Basics of Elliptic Curve Cryptography implementation on Python | |
| import collections | |
| def inv(n, q): | |
| """div on PN modulo a/b mod q as a * inv(b, q) mod q | |
| >>> assert n * inv(n, q) % q == 1 | |
| """ | |
| for i in range(q): | |
| if (n * i) % q == 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
| # fork of sekondus / gist:4322469 | |
| # small changed to make it working on python3 | |
| # Crypto.Cipher is not a part of python base package | |
| # on debian python3-crypto is required | |
| from Crypto.Cipher import AES | |
| import base64 | |
| import os | |
| # the block size for the cipher object; must be 16, 24, or 32 for AES |
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 random | |
| from itertools import combinations | |
| import math | |
| import copy | |
| def euclid(a, b): | |
| '''returns the Greatest Common Divisor of a and b''' | |
| a = abs(a) | |
| b = abs(b) |