Advertisement
Guest User

Untitled

a guest
Aug 29th, 2011
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. rom Crypto import PublicKey
  2. from Crypto.Hash import MD5
  3. from Crypto.Util import number
  4.  
  5. with open('public.pem') as f:
  6.     pubKey = f.read()
  7.  
  8. with open('private.pem') as f:
  9.     prvKeyData = f.read()
  10.  
  11. with open('data.txt') as f:
  12.     data = f.read()
  13.  
  14. with open('signature') as f:
  15.     signature = f.read()
  16.  
  17. hash = MD5.new(data).hexdigest()
  18.  
  19. prvKey = PublicKey.RSA.importKey(prvKeyData)
  20. pub = prvKey.publickey()
  21.  
  22. longSignature = number.bytes_to_long(signature)
  23. print 'VERIFY:', pub.verify(hash, (longSignature,) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement