
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
python-anvil-encryption
Advanced tools
This library is a small wrapper around the pypa/cryptography
library.
It offers convenience methods for encrypting and decrypting arbitrary payloads in both AES and RSA.
For use encrypting / decrypting payloads in Anvil, you can generate an RSA keypair from your organization's settings page.
Anvil provides easy APIs for all things paperwork.
Learn more about Anvil on our Anvil developer page.
Install it directly into an activated virtual environment:
$ pip install python-anvil-encryption
or add it to your Poetry project:
$ poetry add python-anvil-encryption
This usage example is also in a runnable form in the examples/
directory.
import os
from python_anvil_encryption import encryption
CURRENT_PATH = os.path.dirname(os.path.realpath(__file__))
# Keys could be read from a file (or preferably from environment variables)
public_key = None
private_key = None
with open(os.path.join(CURRENT_PATH, "keys/public.pub"), "rb") as pub_file:
public_key = pub_file.read()
with open(os.path.join(CURRENT_PATH, "./keys/private.pem"), "rb") as priv_file:
private_key = priv_file.read()
# RSA
message = b"Super secret message"
encrypted_message = encryption.encrypt_rsa(public_key, message)
decrypted_message = encryption.decrypt_rsa(private_key, encrypted_message)
assert decrypted_message == message
print(f"Are equal? {decrypted_message == message}")
# AES
aes_key = encryption.generate_aes_key()
aes_encrypted_message = encryption.encrypt_aes(aes_key, message)
# The aes key in the first parameter is required to be in a hex
# byte string format.
decrypted_message = encryption.decrypt_aes(
aes_key.hex().encode(),
aes_encrypted_message
)
assert decrypted_message == message
print(f"Are equal? {decrypted_message == message}")
FAQs
Encrypt and decrypt payloads in Anvil (https://www.useanvil.com/)
We found that python-anvil-encryption demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.