<commit_before># -*- coding: utf-8 -*-
"""
Created on Thu Jan 28 21:17:37 2016

@author: vsuha
"""

from Crypto.PublicKey import RSA #to install, do 'sudo pip install pycrypto' or 'sudo pip install crypto', i installed so many things I already forgot..oops
from Crypto import Random
from datetime import datetime

device_key = '12345' #from registered-widgets.txt, I guess it doesn't matter how fancy this is since we are encrypting it
timestamp = str(datetime.now()) #we want to encrypt the key & timestamp and pass that to the server

'''
tips for using pycrypto
http://www.laurentluce.com/posts/python-and-cryptography-with-pycrypto/
'''

random_generator = Random.new().read
key = RSA.generate(1024, random_generator)
#print key

'''
First, we extract the public key from the key pair and use it to encrypt some data. 
32 is a random parameter used by the RSA algorithm to encrypt the data. 
This step simulates us publishing the encryption key and someone using it to encrypt some data before sending it to us.
'''
public_key = key.publickey()<commit_msg>added sample code for signing messages<commit_after># -*- coding: utf-8 -*-
"""
Created on Thu Jan 28 21:17:37 2016

@author: vsuha
"""

from Crypto.PublicKey import RSA #to install, do 'sudo pip install pycrypto' or 'sudo pip install crypto', i installed so many things I already forgot..oops
from Crypto import Random
from Crypto.Hash import SHA256
from datetime import datetime

device_key = '12345' #from registered-widgets.txt, I guess it doesn't matter how fancy this is since we are encrypting it
timestamp = str(datetime.now()) #we want to encrypt the key & timestamp and pass that to the server

'''
tips for using pycrypto
http://www.laurentluce.com/posts/python-and-cryptography-with-pycrypto/
'''

random_generator = Random.new().read
key = RSA.generate(1024, random_generator)
#print key

#try to sign the key, this code crashes my IDE...
'''
hash = SHA256.new(device_key).digest()
signature = key.sign(hash, '')
'''


'''
First, we extract the public key from the key pair and use it to encrypt some data. 
32 is a random parameter used by the RSA algorithm to encrypt the data. 
This step simulates us publishing the encryption key and someone using it to encrypt some data before sending it to us.
'''
public_key = key.publickey()
{'fraction_non_alphanumeric': 0.09019947961838681, 'fraction_numerical': 0.023417172593235037, 'mean_word_length': 4.441037735849057, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3995413', 'n_tokens_mistral': 712, 'n_tokens_neox': 641, 'n_words': 308}