Skip to content

Instantly share code, notes, and snippets.

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
@MooN91
MooN91 / ecc.py
Created March 24, 2014 08:48 — forked from bellbind/ecc.py
# 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:
# 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
@MooN91
MooN91 / RSA.py
Created March 24, 2014 04:25 — forked from avalonalex/RSA.py
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)