MCPcopy Index your code
hub / github.com/pyload/pyload / sign_string

Function sign_string

module/plugins/internal/misc.py:242–258  ·  view source on GitHub ↗

Generate a signature for string using the `sign_algo` and `RSA` algorithms

(message, pem_private, pem_passphrase="" , sign_algo="SHA384")

Source from the content-addressed store, hash-verified

240 return run
241
242def sign_string(message, pem_private, pem_passphrase="" , sign_algo="SHA384"):
243 """
244 Generate a signature for string using the `sign_algo` and `RSA` algorithms
245 """
246 from Crypto.PublicKey import RSA
247 from Crypto.Signature import PKCS1_v1_5
248 from binascii import b2a_hex
249
250 if sign_algo not in ("MD5", "SHA1", "SHA256", "SHA384", "SHA512"):
251 raise ValueError("Unsupported Signing algorithm")
252
253
254 priv_key = RSA.importKey(pem_private, passphrase=pem_passphrase)
255 signer = PKCS1_v1_5.new(priv_key)
256 digest = getattr(__import__('Crypto.Hash', fromlist=[sign_algo]), sign_algo).new()
257 digest.update(message)
258 return b2a_hex(signer.sign(digest))
259
260def format_time(value):
261 dt = datetime.datetime(1, 1, 1) + \

Callers 2

ReCaptcha.pyFile · 0.85
CoinHive.pyFile · 0.85

Calls 2

newMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected