-
Notifications
You must be signed in to change notification settings - Fork 1
/
crypt.py
36 lines (26 loc) · 823 Bytes
/
crypt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import gnupg
from .utils import which
def getgpg(path):
return gnupg.GPG(binary=which("gpg"), homedir=path)
def generate_key_input(path, passphrase):
return getgpg(path).gen_key_input(
name_real="Pysswords",
name_email="pysswords@pysswords",
name_comment="Auto-generated by Pysswords",
key_length=4096,
key_type="RSA",
subkey_type="RSA",
expire_date=0,
passphrase=passphrase)
def generate_keys(path, key_input):
key = getgpg(path).gen_key(key_input)
return key
def create_keyring(path, passphrase):
key_input = generate_key_input(path, passphrase)
generate_keys(path, key_input)
return path
def is_encrypted(data):
if data.startswith("-----BEGIN PGP MESSAGE-----"):
return True
else:
return False