Encrypt a Unicode string using the public key.
(public_key: str, secret_value: str)
| 51 | |
| 52 | |
| 53 | def encrypt(public_key: str, secret_value: str) -> str: |
| 54 | """ |
| 55 | Encrypt a Unicode string using the public key. |
| 56 | """ |
| 57 | pk = public.PublicKey(public_key.encode("utf-8"), encoding.Base64Encoder) |
| 58 | sealed_box = public.SealedBox(pk) |
| 59 | encrypted = sealed_box.encrypt(secret_value.encode("utf-8")) |
| 60 | return b64encode(encrypted).decode("utf-8") |
| 61 | |
| 62 | |
| 63 | class PublicKey(CompletableGithubObject): |