Browse Source

def gpg_decrypt(path, verify=False)

Fabian Peter Hammerle 5 years ago
parent
commit
06623516fd
1 changed files with 7 additions and 0 deletions
  1. 7 0
      rc.xsh

+ 7 - 0
rc.xsh

@@ -189,6 +189,13 @@ def dpkg_which(cmd):
     assert len(matches) == 1
     return matches[0]
 
+def gpg_decrypt(path, verify=False):
+    import gpg
+    with gpg.Context() as gpg_ctx:
+        with open(path, 'rb') as f:
+            data, decrypt_result, verify_result = gpg_ctx.decrypt(f, verify=verify)
+    return data
+
 def locate(*patterns, match_all=True, ignore_case=True):
     params = []
     if match_all: