Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from Crypto.Signature import PKCS1_v1_5
- from Crypto.Hash import SHA512
- from Crypto.PublicKey import RSA
- import base64
- while True:
- nama_file = raw_input("Nama file: ")
- try:
- inp_file = open(nama_file,"r").read()
- inp_file = inp_file.rsplit("\xff\xff\x00\x00MULAI_HASH\x00\x00\xff\xff",1)
- break
- except Exception, e:
- print e
- print "File Tidak Ditemukan"
- continue
- message = inp_file[0]
- signature_enc = inp_file[1]
- signature_dec = str(base64.b64decode (signature_enc))
- # print signature_dec
- key = RSA.importKey(open('public_key.pub').read())
- h = SHA512.new(message)
- verifier = PKCS1_v1_5.new(key)
- if verifier.verify(h, signature_dec):
- print "The signature is authentic."
- else:
- print "The signature is not authentic."
Add Comment
Please, Sign In to add comment