A Library to get Keys from a keyserver specified
Project description
# hkp4py
A Library to get GPG/PGP keys from a Keyserver.
This library uses the requests module to get the keys.
## Tested Python Versions
### Python 2.7
* 2.7.15
### Python 3
* 3.7
## Intstall via [AUR](https://aur.archlinux.org/packages/python-hkp4py-git/)
## KeyServer
This object represents a keyserver using the hkp protocol.
### Initialize
Initialize the KeyServer object.
```python
from hkp4py import KeyServer
server = KeyServer("hkps://pgp.ext.selfnet.de")
```
### Add
Add keys to a keyserver.
```python
key = "a long key"
server.add(key)
```
### Search
Find keys with the keyserver object.
```python
keys = server.search('@gnupg.org') # search by string
keys = server.search('0x{}'.format('6F4B4E15768C8C4E'), exact=True) #search by fingerprint
```
### Key Object
```python
for key in keys:
# Key Basic Information
print("Key Algorithm:\t{}".format(key.algo))
print("Key fpr:\t{}".format(key.keyid))
print("Key Length:\t{}".format(key.key_length))
print("Disabled?\t{}".format('yes' if key.disabled else 'no'))
print("Expired?\t{}".format('yes' if key.expired else 'no'))
print("Revoked?\t{}".format('yes' if key.revoked else 'no'))
print("From Host:\t{}".format(key.host))
print("From Port:\t{}".format(key.port))
print("Date Created:\t{}".format(key.creation_date))
print("Date Expired:\t{}".format(key.expiration_date))
print(key.key)
```
#### Identity Object
```python
for identity in key.identities:
print("Identity:\t{}".format(identity.uid))
print("\tDisabled?\t{}".format('yes' if identity.disabled else 'no'))
print("\tExpired?\t{}".format('yes' if identity.expired else 'no'))
print("\tRevoked?\t{}".format('yes' if identity.revoked else 'no'))
print("\tDate Created:\t{}".format(identity.creation_date))
print("\tDate Expired:\t{}".format(identity.expiration_date))
```
## More Advanced options
To set a different User-Agent and proxies for veiling purposes.
The KeyServer has the following additional options for the connection.
```python
server = KeyServer("hkps://pgp.ext.selfnet.de",
proxies={"http": "socks5h://localhost:5050", "https":
"socks5h://localhost:5050"},
headers={"User-Agent": "Testing"})
```
## Import key with gpgme python bindings
```python
import gpg
with gpg.Context(armor=True, home_dir=HOME) as gnupg:
result = gnupg.op_import(key.key.encode('ascii'))
```
A Library to get GPG/PGP keys from a Keyserver.
This library uses the requests module to get the keys.
## Tested Python Versions
### Python 2.7
* 2.7.15
### Python 3
* 3.7
## Intstall via [AUR](https://aur.archlinux.org/packages/python-hkp4py-git/)
## KeyServer
This object represents a keyserver using the hkp protocol.
### Initialize
Initialize the KeyServer object.
```python
from hkp4py import KeyServer
server = KeyServer("hkps://pgp.ext.selfnet.de")
```
### Add
Add keys to a keyserver.
```python
key = "a long key"
server.add(key)
```
### Search
Find keys with the keyserver object.
```python
keys = server.search('@gnupg.org') # search by string
keys = server.search('0x{}'.format('6F4B4E15768C8C4E'), exact=True) #search by fingerprint
```
### Key Object
```python
for key in keys:
# Key Basic Information
print("Key Algorithm:\t{}".format(key.algo))
print("Key fpr:\t{}".format(key.keyid))
print("Key Length:\t{}".format(key.key_length))
print("Disabled?\t{}".format('yes' if key.disabled else 'no'))
print("Expired?\t{}".format('yes' if key.expired else 'no'))
print("Revoked?\t{}".format('yes' if key.revoked else 'no'))
print("From Host:\t{}".format(key.host))
print("From Port:\t{}".format(key.port))
print("Date Created:\t{}".format(key.creation_date))
print("Date Expired:\t{}".format(key.expiration_date))
print(key.key)
```
#### Identity Object
```python
for identity in key.identities:
print("Identity:\t{}".format(identity.uid))
print("\tDisabled?\t{}".format('yes' if identity.disabled else 'no'))
print("\tExpired?\t{}".format('yes' if identity.expired else 'no'))
print("\tRevoked?\t{}".format('yes' if identity.revoked else 'no'))
print("\tDate Created:\t{}".format(identity.creation_date))
print("\tDate Expired:\t{}".format(identity.expiration_date))
```
## More Advanced options
To set a different User-Agent and proxies for veiling purposes.
The KeyServer has the following additional options for the connection.
```python
server = KeyServer("hkps://pgp.ext.selfnet.de",
proxies={"http": "socks5h://localhost:5050", "https":
"socks5h://localhost:5050"},
headers={"User-Agent": "Testing"})
```
## Import key with gpgme python bindings
```python
import gpg
with gpg.Context(armor=True, home_dir=HOME) as gnupg:
result = gnupg.op_import(key.key.encode('ascii'))
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hkp4py-0.2.0.0.tar.gz
(5.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hkp4py-0.2.0.0.tar.gz.
File metadata
- Download URL: hkp4py-0.2.0.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
239a467ce5a323022f4f0ba5a1dd25e7c986e05b2b0a757ee6b4fd76f1ca8e7f
|
|
| MD5 |
4760eaeeb02a61ee220071f2e44cb875
|
|
| BLAKE2b-256 |
2feeede82229e7bbecc3f489ec902690b5eed13e82a797be58128618e6c1dd70
|
File details
Details for the file hkp4py-0.2.0.0-py3-none-any.whl.
File metadata
- Download URL: hkp4py-0.2.0.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40b5e60de68a9a3d6d91520e99531b1a95a06d73030f535e5353fd2ae1a5121a
|
|
| MD5 |
336c73b1647d5a59e2bfa8fabc699b38
|
|
| BLAKE2b-256 |
342b07625d14ef45cc0c54bd55f50c1eea7e53391348b99b0a985dddd8dd15c4
|