Guest User

Untitled

a guest
May 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. from Crypto.Signature import PKCS1_v1_5
  2. from Crypto.Hash import SHA512
  3. from Crypto.PublicKey import RSA
  4. import base64
  5.  
  6. while True:
  7. nama_file = raw_input("Nama file: ")
  8. try:
  9. inp_file = open(nama_file,"r").read()
  10. inp_file = inp_file.rsplit("\xff\xff\x00\x00MULAI_HASH\x00\x00\xff\xff",1)
  11. break
  12. except Exception, e:
  13. print e
  14. print "File Tidak Ditemukan"
  15. continue
  16.  
  17. message = inp_file[0]
  18. signature_enc = inp_file[1]
  19. signature_dec = str(base64.b64decode (signature_enc))
  20. # print signature_dec
  21. key = RSA.importKey(open('public_key.pub').read())
  22. h = SHA512.new(message)
  23. verifier = PKCS1_v1_5.new(key)
  24. if verifier.verify(h, signature_dec):
  25. print "The signature is authentic."
  26. else:
  27. print "The signature is not authentic."
Add Comment
Please, Sign In to add comment