Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zlobendog/polars_encryption
A Polars plugin for encrypting and decrypting data using AES-GSM-CIV algorithm in Rust
https://github.com/zlobendog/polars_encryption
Last synced: 2 months ago
JSON representation
A Polars plugin for encrypting and decrypting data using AES-GSM-CIV algorithm in Rust
- Host: GitHub
- URL: https://github.com/zlobendog/polars_encryption
- Owner: zlobendog
- License: gpl-3.0
- Created: 2024-06-06T10:25:51.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-06-08T08:35:15.000Z (8 months ago)
- Last Synced: 2024-08-05T14:15:56.696Z (6 months ago)
- Language: Python
- Size: 72.3 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-polars - polars_encryption - Polars plugin that extends Polars with encryption algorithm AES-GSM-SIV by [@zlobendog](https://github.com/zlobendog). (Libraries/Packages/Scripts / Polars plugins)
README
# Polars Encryption
This is a plugin to extend Polars with encryption algorithm **AES-GSM-SIV** written in Rust for a blazing fast (c) performance.
# Sources
This plugin is built using a guide by [Marco Gorelli](https://marcogorelli.github.io/polars-plugins-tutorial/).
The encryption algorithm crate is [this](https://docs.rs/aes-gcm-siv/latest/aes_gcm_siv/). The specific implementation is a 256bit version of it.
## Usage
There are two methods: encrypt and decrypt. Both require key and nonce, as per algorithm specification.
```python
import polars as pl
from polars_encryption import encrypt, decrypt# Define the DataFrame
df = pl.DataFrame({
"plaintext": ["Hello, world!", "Polars is fast!", "Encrypt me!"]
})# Define the encryption key and nonce
key = b"an example very very secret key."
nonce = b"unique nonce" # 12 bytes (96 bits)# Encrypt the plaintext column
df_encrypted = df.with_columns(
encrypt(pl.col("plaintext"), key=key, nonce=nonce).alias("ciphertext")).with_columns(decrypt(pl.col("ciphertext"), key=key, nonce=nonce).alias("decrypted"))print((df["plaintext"] == df_encrypted["decrypted"]).all())
print(df_encrypted)
```