I have been getting my hands dirty figuring out the python-gnupg module and am pleased that
``` demogpg.py
import gnupg
gpg = gnupg.GPG(gnupghome='/home/ian/.gnupg')
print(gpg)
message = """
Copyright (c) 2021, Ian Stanley
All rights reserved.
"""
recipients = 'test@noteslib'
data = gpg.encrypt(message, recipients)
print (data.ok)
print (data.status)
print (data)
checkmsg = gpg.decrypt(str(data))
print (checkmsg)
```
When I use the first line with the recipients = '
myemail...@gmail.com' the code runs fine. But when I use the second recipients line I get the following:
<gnupg.GPG object at 0x7fce49c6d040>
False
invalid recipient
Now GNUPG does not enforce a valid email address format (partly because top level domains seem to change each week these days ... but mainly because it is not a requirement of the application that the "email" address field is a valid email address.
A number of developers and sysadmins will create a user@hostname (not domain name) to a key for backup encryption.
The python-gnupg module appears to be validating whether the key is of the form user...@domain.tld when it is not required by GNUPG.
It is not required by GNUPG for one very good reason. Email can be sent between two unix-like systems whose ip address is in the hosts file. So you can use the mail program to email root@myserver and it works.
The test@noteslib key is a valid key. It works for encryption/decryption
For me I can recreate the keys but you may find this breaking for other users.
I believe that the python-gnupg module should follow the gnupg behaviour