Advertisement
Guest User

Untitled

a guest
Sep 6th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. class EncryptedString():
  2.  
  3.  
  4.     def __init__(self,homegpg,user,set_result):
  5.  
  6.         self.homegpg = homegpg
  7.         self.user = user
  8.        
  9.         self.set_result = set_result
  10.     def encrypt_string(self,input_string):
  11.         #Encrypt a string
  12.         self.input_string = input_string
  13.         gpg  =  gnupg.GPG(gnupghome = self.homegpg)
  14.         unencrypted_string  =  self.input_string
  15.         encrypted_data  =  gpg.encrypt(unencrypted_string, self.user)
  16.         encrypted_string  =  str(encrypted_data)
  17.         ok =  encrypted_data.ok
  18.         status =  encrypted_data.status
  19.         stderr =  encrypted_data.stderr
  20.         result = [ok,status,stderr,unencrypted_string,encrypted_string]
  21.         return result[self.set_result]
  22.          
  23. # instantiate
  24. if __name__  ==  "__main__":
  25.     print "Is not shown if import"
  26.    
  27.     homegpg = '../home/gpg/'
  28.     user = '[email protected]'
  29.     input_string = 'string en texto plano'
  30.     set_result = 2
  31.     encryptstring = EncryptedString(homegpg,user,set_result)
  32.     print encryptstring.encrypt_string(input_string)
  33.     print " enjoy "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement