Пример #1
0
 def encrypt_file(self, file_path):
   # GPG-encrypt and hash the file, filepath.
   with open(file_path) as cleartext_file:
     with NamedTemporaryFile(delete=False) as encrypted_blob_file:
       self.path_to_encrypted_blob = encrypted_blob_file.name
       self.gpg.encrypt_file(cleartext_file, self.recipients,
                             always_trust=True, armor=False,
                             output=self.path_to_encrypted_blob)
   self.hash_of_encrypted_blob = hash_filename(self.path_to_encrypted_blob)
Пример #2
0
  def encrypt(self):
    self.encrypt_file(self.file_path)
    self.hash_of_encrypted_blob = hash_filename(self.path_to_encrypted_blob)

    # File path encryption.
    encrypted_blob_path = self.gpg.encrypt(self.file_path, self.recipients,
                                           always_trust=True, armor=False)
    self.raw_data_of_encrypted_blob_path = encrypted_blob_path.data
    self.hash_of_raw_data_of_encrypted_blob_path =\
      hash_string(self.raw_data_of_encrypted_blob_path)