예제 #1
0
파일: encrypt.py 프로젝트: ihoover/crypto
def text_to_points(text):
    """
    
    """
    nums = helpers.text_to_nums(text, 15)
    points =  [num_to_point(num) for num in nums]
    return points
예제 #2
0
파일: encrypt.py 프로젝트: ihoover/crypto
def encrypt_text(text):
    
    nums = helpers.text_to_nums(text, 127)
    return encrypt_nums(nums)
예제 #3
0
파일: encrypt.py 프로젝트: ihoover/crypto
import sys
import pub
import os
sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), os.pardir)))
import arith
import helpers

def encrypt_nums(nums):
    
    return [arith.powm(byte, pub.exponent, pub.modulus) for byte in nums]

def encrypt_text(text):
    
    nums = helpers.text_to_nums(text, 127)
    return encrypt_nums(nums)

if __name__ == "__main__":
    # string to encrypt
    plaintext = sys.argv[1]
    
    # turn into numbers    
    plain_nums = helpers.text_to_nums(plaintext)
    
    # encrypt
    cypher = [arith.powm(byte, pub.exponent, pub.modulus) for byte in plain_nums]
    print encrypt_text(plaintext)