giftcrypt
Encryption and decryption of 16–19 digit gift card numbers (physical and virtual).
Version: 1.0.3
Overview
giftcrypt is a Python package used by the GC Activation Orchestrator to encrypt
a plain 16–19 digit gift card number before writing it to Vault DB, and to decrypt it
when reading back.
Two backends are supported:
| Backend | Mechanism | When to use |
|---|---|---|
gcm |
AES-256-GCM local key | Local development and testing |
kms_wrapped |
AWS KMS envelope encryption | Production (recommended) |
Installation
pip install cryptography # for gcm backend
pip install cryptography boto3 # for kms_wrapped backend
Usage
The only function the Orchestrator needs to call is in vault.py:
from giftcrypt.vault import encrypt_card_number, decrypt_card_number
Local / dev testing (GCM backend)
No AWS needed. Uses a local secret key.
from giftcrypt.vault import encrypt_card_number, decrypt_card_number
key = "my-secret-encryption-key"
# Encrypt — after SVS activates the card (PGC or VGC)
ciphertext = encrypt_card_number(
"1234567890123456",
backend="gcm",
key=key,
)
# → store ciphertext in Vault DB
# Decrypt — when reading back from Vault DB
card_number = decrypt_card_number(ciphertext, backend="gcm", key=key)
assert card_number == "1234567890123456"
Production (KMS wrapped backend)
Requires AWS account and KMS key. Card number never leaves your Lambda.
from giftcrypt.vault import encrypt_card_number, decrypt_card_number
KEY_ALIAS = "alias/giftcard-key"
REGION = "us-east-1"
# PGC — card number from KIBO shipment swipe
# VGC — card number freshly issued by SVS
# Both use the exact same call:
ciphertext = encrypt_card_number(
"1234567890123456",
backend="kms_wrapped",
key_alias=KEY_ALIAS,
region=REGION,
)
# → store ciphertext in Vault DB
card_number = decrypt_card_number(ciphertext, backend="kms_wrapped", region=REGION)
assert card_number == "1234567890123456"
Input formats accepted
Dashes and spaces are stripped automatically before encryption:
encrypt_card_number("1234567890123456") # plain
encrypt_card_number("1234-5678-9012-3456") # dashes stripped
encrypt_card_number("1234 5678 9012 3456") # spaces stripped
# all three store the same normalised value: "1234567890123456"
Package structure
giftcrypt/
├── giftcrypt/
│ ├── __init__.py # package entry point
│ ├── vault.py # primary interface — validate, normalise, route
│ ├── gcm.py # AES-256-GCM local encryption
│ └── kms_wrapped.py # AWS KMS envelope encryption
└── tests/
├── test_gcm.py # 10 tests
└── test_vault.py # 21 tests
Running tests
No AWS account needed — KMS is fully mocked:
py -m pytest tests/ -v
Expected output:
31 passed in 0.82s
AWS KMS setup (for production)
- Create an AWS account at https://aws.amazon.com/free
- Create a KMS key in AWS Console → KMS → Create key
- Set alias to
alias/giftcard-key - Run
aws configureon your machine to set up credentials - Create
conf/test.yml:
aws:
profile: your_aws_profile
region: us-east-1
key_alias: alias/giftcard-key
- Run the KMS smoke test:
py kms_smoke_test.py
Ciphertext envelope formats
GCM envelope — pipe-separated, base64url-encoded:
v1|<iv>|<tag>|<aad>|<ciphertext>
KMS wrapped envelope — base64-encoded JSON:
{
"version": "kms-wrapped-v1",
"key_id": "arn:aws:kms:us-east-1:...",
"wrapped_data_key": "...",
"iv": "...",
"ciphertext": "..."
}
License
MIT
Metadata
Release files for giftcrypt 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| giftcrypt-1.0.3.tar.gz | 12.7 kB | Without provenance | Details for giftcrypt-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| giftcrypt-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for giftcrypt-1.0.3-py3-none-any.whl |
Total release size: 23.9 kB
Release files / giftcrypt-1.0.3.tar.gz
| Download URL | giftcrypt-1.0.3.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e5710ef3b4419afbd8e63f28e74b5ea8f02df4353a2083fc061b161a37af2aab
|
|
BLAKE2b-256 checksum How to use checksums |
7d882cf39f578e1d3e19c4998eae204823a3acfee43664d16918d915b6f6708b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / giftcrypt-1.0.3-py3-none-any.whl
| Download URL | giftcrypt-1.0.3-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
458ab09ef66db5db4ab117a33808e43b7930b2f461706459dc4f11fcce65fbb3
|
|
BLAKE2b-256 checksum How to use checksums |
e768a96ca8e6da1cfd4116ae689df39aff27a4314890cfeb662abf681c575c02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for giftcrypt 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.