Skip to main content

Installation

This library uses PyCryptodome which means a C compiler is required. For Mac and Linux users this is already installed. For Windows users please follow this guide from PyCryptoDome.

https://pycryptodome.readthedocs.io/en/latest/src/installation.html#windows-from-sources

Usage

The libray is imported as from FPE import FPE.

To generate a tweak use FPE.generate_tweak(tweak_length) where tweak_len is the length of the tweak in bytes. Note that for FF3-1 the tweak_length must be 7 bytes.

To generate a key use FPE.generate_key(), this will generate a 16 byte key.

To make a cipher object use cipher = FPE.New(key,tweak,mode)

Currently supported modes are Mode.FF1 and Mode.FF3-1

To encrypt use cipher.encrypt(plaintext,format)

Currently supported formats are:

Format.DIGITS
Format.CREDITCARD
Format.LETTERS
Format.STRING
Format.EMAIL
Format.CPR

to decrypt use cipher.decrypt(ciphertext,format)

The library also supports CSV files

To encrypt a csv file use cipher.encryptCSV(InputFilePath,OutputFilePath,formats) where formats is a list of formats sorted by the columns

To decrypt a csv file use cipher.decryptCSV(InputFilePath,OutputFilePath,formats)

to generate a random CSV file with certain formats use cipher.generateData(OutputFilePath,rows,formats,variables) where rows define the number of rows in the CSV file. Formats is the lists of formats to use. Variables is the list of variable names used for the first row.

Examples

Example of encrypting and decrypting "123456" as DIGITS and printing the output

from FPE import FPE

if __name__ == '__main__':

	T = FPE.generate_tweak(8)
	
	key = FPE.generate_key()
	
	cipher = FPE.New(key,T,FPE.Mode.FF1)
	
	ciphertext = cipher.encrypt('123456',FPE.Format.DIGITS)
	
	print(ciphertext)
	
	plaintext = cipher.decrypt(ciphertext,FPE.Format.DIGITS)
	
	print(plaintext)

Example of generating, encrypting and decrypting a 1000 row CSV file

from FPE import FPE, Format

variables = [
	'Username','Password','Email','PhoneNumber','Cpr-number',
	'Creditcard','adress','city','zip','country'
]


formats = [
	Format.LETTERS, Format.STRING, Format.EMAIL, Format.DIGITS,
	Format.CPR, Format.CREDITCARD,Format.STRING,Format.LETTERS,
	Format.DIGITS,Format.LETTERS
]

if __name__ == '__main__':
	
	T = FPE.generate_tweak(7)
	key = FPE.generate_key()
	cipher = FPE.New(key,T,FPE.Mode.FF3)
	cipher.generateData('testData.csv',1000,formats,variables)
	cipher.encryptCSV('testData.csv','encryptedData.csv',formats)
	cipher.decryptCSV('encryptedData.csv','decryptedData.csv',formats)

Metadata

Release files for FPE 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for FPE 0.1.2
File Size Uploaded Provenance Actions
FPE-0.1.2.tar.gz 117.8 kB Without provenance Details for FPE-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for FPE 0.1.2
File Interpreter ABI Platform Actions
FPE-0.1.2-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details for FPE-0.1.2-cp39-cp39-win_amd64.whl

Total release size: 199.4 kB

Release files / FPE-0.1.2.tar.gz

Download URL FPE-0.1.2.tar.gz
Size 117.8 kB
Tags Source
SHA-256 checksum
How to use checksums
68d2071d2ca6e792fabea204d16cbcbe32634b87037a2508533108b3b6d2904a
BLAKE2b-256 checksum
How to use checksums
d3699878654c24788d6d442c45cc422fd326bfae9f0fb1bdaedfb8264517ed75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

Release files / FPE-0.1.2-cp39-cp39-win_amd64.whl

Download URL FPE-0.1.2-cp39-cp39-win_amd64.whl
Size 81.6 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
0488ff545154a4443b1bc751ce564097728dceba2d5fa2da9e3cf8bcdbbf3b4e
BLAKE2b-256 checksum
How to use checksums
1020bff9d3e3241110d8dce9d8708a36062cd91c4fc2489929b1bcf1983d4b8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

Security for FPE 0.1.2

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page