def test_roundtrip_plain(self):
     keys = generate_keys()
     priv = keys['privateKey']
     pub = keys['publicKey']
     c = 0
     while c < 1000:
         # message = "My name is Ryan.  Here is some french text:  Maître Corbeau, sur un arbre perché.  Now some Chinese: 鋈 晛桼桾 枲柊氠 藶藽 歾炂盵 犈犆犅 壾, 軹軦軵 寁崏庲 摮 蟼襛 蝩覤 蜭蜸覟 駽髾髽 忷扴汥 "
         message = self.id_generator(500)
         cipher = encrypt(pub, message)
         plain = decrypt(priv, cipher)
         assert message == plain
         c += 1
Пример #2
0
def make_key_pair(iNumBits=256, iConfidence=32):
    # make a private/public key pair
    # TODO add p and t options for generate key
    e = generate_keys()
    ekeys = dict()
    ekeys['TwitterKey'] = make_twitter_public(e['publicKey'])
    ekeys['PrivateKey'] = {
        'p': e['privateKey'].p,
        'g': e['privateKey'].g,
        'x': e['privateKey'].x,
        'iNumBits': e['privateKey'].iNumBits
    }
    ekeys['PublicKey'] = {
        'p': e['publicKey'].p,
        'g': e['publicKey'].g,
        'h': e['publicKey'].h,
        'iNumBits': e['publicKey'].iNumBits
    }
    return ekeys