MCPcopy
hub / github.com/wechatpy/wechatpy / test_rsa_encrypt_decrypt

Method test_rsa_encrypt_decrypt

tests/test_utils.py:86–92  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

84
85 @pytest.mark.skipif(skip_if_no_cryptography(), reason='cryptography not installed')
86 def test_rsa_encrypt_decrypt(self):
87 from wechatpy.pay.utils import rsa_encrypt, rsa_decrypt
88 target_string = 'hello world'
89 with open(os.path.join(_CERTS_PATH, 'rsa_public_key.pem'), 'rb') as public_fp, \
90 open(os.path.join(_CERTS_PATH, 'rsa_private_key.pem'), 'rb') as private_fp:
91 encrypted_string = rsa_encrypt(target_string, public_fp.read(), b64_encode=False)
92 self.assertEqual(rsa_decrypt(encrypted_string, private_fp.read()), target_string.encode('utf-8'))

Callers

nothing calls this directly

Calls 3

rsa_encryptFunction · 0.90
rsa_decryptFunction · 0.90
encodeMethod · 0.80

Tested by

no test coverage detected