Skip to content

sittiponghaus/fpe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TypeScript Format-Preserving Encryption

Build with Claude.ai, document with Codeium.

Usage

You need key and tweak to use this function, you may generate one using nanoid

Encrypt

encrypt(idString, key, tweak);

Decrypt

decrypt(String(encryptedId), key, tweak);

EncryptId

encryptId(Number(c.req.param("id")), key, tweak);

DecryptId

decryptId(c.req.param("id"), key, tweak);

Performance

Tested with 1M generated IDs (1-1,000,000), including encryption and decryption of all IDs (run on Mac Mini M1, 16GB RAM).

Times shown below are in ms.

{
  "totalIds": "1,000,000",
  "generatedTime": 76,
  "encryptedTime": 1863,
  "decryptedTime": 1803
}

Security?

No idea, zero knowledge at all.

Feedback or PRs are welcome

About

Format Preserving Encryption

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published