1. Please install python "cryptography" library: pip install cryptography 2. Convert "text" to a signature. import hashlib from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric import padding from cryptography.hazmat.primitives import hashes # Read the content of the private key. with open('mytproof.key', 'rb') as key_file: private_key = serialization.load_pem_private_key( key_file.read(), password=None, backend=default_backend() ) # Calculate the signature of the string. string_to_sign = b'Your string 12345' signature = private_key.sign( string_to_sign, padding.PKCS1v15(), hashes.SHA256() ) # Display the obtained signature value (displayed in hex format) print(signature.hex()) 3. Convert "file" to a signature. import hashlib from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric import padding from cryptography.hazmat.primitives import hashes # Calculate the signature of the test.txt file. with open('test.txt', 'rb') as file: file_content = file.read() # Read the private key. with open('mytproof.key', 'rb') as key_file: private_key = serialization.load_pem_private_key( key_file.read(), password=None, backend=default_backend() ) # Sign the file content using the private key. signature = private_key.sign( file_content, padding.PKCS1v15(), hashes.SHA256() ) # Display the obtained signature value (displayed in hex format) print(signature.hex())