-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
decrypt accepts the output from tar. For #21
- Loading branch information
1 parent
388cf9d
commit baaa1e5
Showing
9 changed files
with
195 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
decrypt.py | ||
Reads filenames from STDIN, and uses gpg to decrypt files ending in .gpg | ||
Usage: | ||
> ls | ||
1.txt.gpg | ||
> echo "1.txt.gpg" | python -m pydiode.decrypt | ||
> ls | ||
1.txt | ||
1.txt.gpg | ||
""" | ||
|
||
from pathlib import Path | ||
import subprocess | ||
import sys | ||
|
||
|
||
def main(): | ||
for line in sys.stdin: | ||
path = Path(line.strip()) | ||
if path.exists() and path.suffix == ".gpg": | ||
subprocess.run( | ||
[ | ||
"gpg", | ||
"--batch", | ||
"--yes", | ||
"--quiet", | ||
"--output", | ||
path.with_suffix(""), | ||
"--decrypt", | ||
path, | ||
] | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
-----BEGIN PGP PRIVATE KEY BLOCK----- | ||
|
||
lQcYBGaeaDABEACzd9zDr+/95tODrEVlBHfg7OPW9DXDKhzV+svuIbTroXJsJQ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eR00EPS/WXJmlMYMYNi7J+LaC+U75NtbGg | ||
WzuEQcatzUc1cTEJV1axXfCckUs0mPOv1GguuinUFFmkZsP6tNJ7Fy0bbgzEx1Ed | ||
GqjgnYZNQznzWp0FxzYYsuWDxNhbHn5+dyeFpQiaCu5EW6O2uHLIPoFAHXYpFEQG | ||
atJu6tHOMIRsLBhQZeVo0WCmAmcwoMX1OjrZeVGy0fJdQd5yy8YN0mKG4x/Ax9Xd | ||
MpdCoy+ieCIXNgURRr2OnWL9TGUTiUepKuqn6HHpTf20okxGikwMGuXOhuK5IXsd | ||
Ns8MCafm1KdKuU7tj0OGR3iBIXxLiGitb0YtcEWj5IloOoPS572raHD3N83x6u9Z | ||
WCM= | ||
=Zub4 | ||
-----END PGP PRIVATE KEY BLOCK----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from pathlib import Path | ||
import shutil | ||
import subprocess | ||
import sys | ||
import tempfile | ||
import unittest | ||
|
||
PARENT_DIR = Path(__file__).parent | ||
|
||
|
||
class TestDecrypt(unittest.TestCase): | ||
def setUp(self): | ||
subprocess.run( | ||
["gpg", "--import", PARENT_DIR / "PRIVATE.asc"], | ||
capture_output=True, | ||
check=True, | ||
) | ||
|
||
def test_decrypt(self): | ||
files = { | ||
Path("1.txt.gpg"): "ABC", | ||
Path("2.txt.gpg"): "DEF", | ||
Path("3.txt.gpg"): "GHI", | ||
} | ||
|
||
with tempfile.TemporaryDirectory() as tmpdir: | ||
# Copy the encrypted files | ||
for file in files: | ||
shutil.copy(PARENT_DIR / file, tmpdir) | ||
|
||
# Decrypt the files | ||
decrypt = subprocess.run( | ||
[sys.executable, "-m", "pydiode.decrypt"], | ||
input="\n".join([str(tmpdir / file) for file in files.keys()]), | ||
text=True, | ||
) | ||
|
||
# Check the files were decrypted | ||
for file, data in files.items(): | ||
with open(tmpdir / file.with_suffix(""), "r") as f: | ||
self.assertEqual(data, f.read().strip()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters