예제 #1
0
파일: dao.py 프로젝트: f80dev/elMoney
 def save_pem(self, addr, pem=""):
     #TODO: ajouter le cryptage de l'email
     if not pem.endswith(".pem"):
         pem = base64.b64encode(aes256.encrypt(pem, SECRET_KEY))
     body = {'addr': addr, "pem": pem}
     if self.db:
         rc = self.db["users"].replace_one(filter={"addr": addr},
                                           replacement=body,
                                           upsert=True)
         return rc.modified_count > 0 or (rc.upserted_id is not None), pem
     else:
         log("Impossible d'enregistrer le PEM")
         return False, pem
예제 #2
0
파일: test.py 프로젝트: iridesc/ResdigB
    'keyword': '机械师',
    # 'reason': 'sendFeedback',
    # 'info':'hahahha'
    # 'reason': 'sendMsg',
    # 'info':'hahahhaisdg\>>'
}

# encryption
# encrypted = aes256.encrypt("TEXT", "PASSWORD")
# print(encrypted)

# # decryption
# print(aes256.decrypt(encrypted, "PASSWORD"))

r = requests.post('https://resdig.net/api/',
                  data=aes256.encrypt(json.dumps(data), PASSWORD))
print(r.status_code)
print(aes256.decrypt(r.content, PASSWORD))
# # 测试加密解密
# a=json.dumps({})

# # encryption
# encrypted = aes256.encrypt(a, PASSWORD)
# print(encrypted)
# # decryption
# print(aes256.decrypt(encrypted, 'PASSWORD'))

# e=encrypto(a)
# print(e)
# print('************************')
# d=decrypto(e)
예제 #3
0
 def test_encrypt_decrypt3(self):
     text = "Test! @#$%^&*( 😆😵🤡👌 哈罗 �ん��� �кїў 😺"
     passw = "哈罗 �ん��� �кїў 😺"
     enc = aes256.encrypt(text, passw)
     dec = aes256.decrypt(enc, passw)
     self.assertEqual(u(text), dec, FAIL)
예제 #4
0
 def test_encrypt_decrypt1(self):
     text = "Test! @#$%^&*"
     passw = "pass"
     enc = aes256.encrypt(text, passw)
     dec = aes256.decrypt(enc, passw)
     self.assertEqual(u(text), dec, FAIL)
예제 #5
0
 def test_encrypt_return_type(self):
     enc_text = aes256.encrypt("Test! @#$%^&*( 😆😵🤡👌 哈罗 こんにちわ Акїў 😺",
                               "pass")
     self.assertIsInstance(enc_text, bytes)
예제 #6
0
 def test_encrypt_decrypt3(self):
     text = "Test! @#$%^&*( 😆😵🤡👌 哈罗 こんにちわ Акїў 😺"
     passw = "哈罗 こんにちわ Акїў 😺"
     enc = aes256.encrypt(text, passw)
     dec = aes256.decrypt(enc, passw)
     self.assertEqual(u(text), dec, FAIL)