Facebook
From Arash, 1 Year ago, written in Python.
This paste is a reply to Re: Re: modules from Arash - go back
Embed
Viewing differences between Re: Re: modules and Re: Re: Re: modules
import random
import math as floor


def genKys(length):
              length *= 8
    key = [0] * length
    choice = floor.floor(random.random() * length)
    for i in range(choice):
        key[floor.floor(random.random() * (length - 1))] = 1
    return key

key


def enc(plain, key):
    length = len(key)
    cipher = [None] * length
    for i in range(length):
        cipher[i] = 1 if key[i] == plain[i] else 0
    return cipher

cipher


def getBts(plain):
    length = len(plain)
    bits = [None] * length * 8
    for i in range(length):
        for j in range(8):
            bits[8 * i + 7 - j] = (int)(ord(plain[i]) / pow(2, j)) % 2
    return bits

Replies to Re: Re: Re: modules rss

Title Name Language When
Re: Re: Re: Re: modules Arash python 1 Year ago.