Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class EncryptedString():
- def __init__(self,homegpg,user,set_result):
- self.homegpg = homegpg
- self.user = user
- self.set_result = set_result
- def encrypt_string(self,input_string):
- #Encrypt a string
- self.input_string = input_string
- gpg = gnupg.GPG(gnupghome = self.homegpg)
- unencrypted_string = self.input_string
- # agregar en la siguiente linea always_trust=True
- * * * * encrypted_data = gpg.encrypt(unencrypted_string, self.user,always_trust=True)
- encrypted_string = str(encrypted_data)
- ok = encrypted_data.ok
- status = encrypted_data.status
- stderr = encrypted_data.stderr
- result = [ok,status,stderr,unencrypted_string,encrypted_string]
- return result[self.set_result]
- # instantiate
- if __name__ == "__main__":
- print "Is not shown if import"
- homegpg = '../home/gpg/'
- user = 'user@dominio.com'
- input_string = 'string en texto plano'
- set_result = 2
- encryptstring = EncryptedString(homegpg,user,set_result)
- print encryptstring.encrypt_string(input_string)
- print " enjoy "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement