{"id":17108450,"url":"https://github.com/g-andrade/erlffx","last_synced_at":"2025-04-13T02:48:09.900Z","repository":{"id":51353526,"uuid":"81008404","full_name":"g-andrade/erlffx","owner":"g-andrade","description":"Format Preserving Encryption - FFX","archived":false,"fork":false,"pushed_at":"2022-04-09T19:11:23.000Z","size":67,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T02:47:49.055Z","etag":null,"topics":["erlang","ffx","format-preserving-encryption"],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/g-andrade.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-05T17:21:22.000Z","updated_at":"2024-04-24T18:28:45.000Z","dependencies_parsed_at":"2022-09-26T21:40:56.515Z","dependency_job_id":null,"html_url":"https://github.com/g-andrade/erlffx","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-andrade%2Ferlffx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-andrade%2Ferlffx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-andrade%2Ferlffx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-andrade%2Ferlffx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/g-andrade","download_url":"https://codeload.github.com/g-andrade/erlffx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657869,"owners_count":21140844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["erlang","ffx","format-preserving-encryption"],"created_at":"2024-10-14T16:05:24.018Z","updated_at":"2025-04-13T02:48:09.880Z","avatar_url":"https://github.com/g-andrade.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# erlffx\n\n**This library is not under active maintenance; if you'd like to perform\nmaintenance yourself, feel free to open an issue requesting access.**\n\n[![](https://img.shields.io/hexpm/v/erlffx.svg?style=flat)](https://hex.pm/packages/erlffx)\n[![](https://github.com/g-andrade/erlffx/workflows/build/badge.svg)](https://github.com/g-andrade/erlffx/actions?query=workflow%3Abuild)\n\n`erlffx` is an Erlang implementation of the mechanism described in the\n2010 paper [The FFX Mode of Operation for Format-Preserving\nEncryption](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.304.1736\u0026rep=rep1\u0026type=pdf)\nby Bellare, Rogaway and Spies. It is based on an existing [Java\nimplementation](https://github.com/michaeltandy/java-ffx-format-preserving-encryption)\nby Michael Tandy.\n\n\\* AES-128 / AES-192 (only Erlang 19 and up) / AES-256 keys are\nsupported (CBC mode) \\* Any positive word length is supported \\* Any\nradix / alphabet size between 2 and 255 is acceptable (10 by default) \\*\nOptional 'tweak' values may be defined \\* Number of rounds is\nconfigurable (10 by default)\n\nThe code was successfully tested on generations 17, 18 and 19 of\nErlang/OTP; the unit tests themselves were written using the following\nlists of test vectors: \\* [AES FFX Test Vector\nData](http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/ffx/aes-ffx-vectors.txt)\n\\* [FF1\nsamples](http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/FF1samples.pdf)\n\n### \u003cspan id=\"Examples\"\u003eExamples\u003c/span\u003e\n\n``` erlang\n% AES-128 CBC / 10-digit decimal words\nAesKey = \u003c\u003c43,126,21,22,40,174,210,166,171,247,21,136,9,207,79,60\u003e\u003e,\nValueLength = 10,\nConfig = erlffx:config(AesKey, ValueLength).\n\nEncrypted = erlffx:encrypt(Config, 123456789). % 2433477484\nDecrypted = erlffx:decrypt(Config, Encrypted). % 123456789\n```\n\n-----\n\n``` erlang\n% AES-128 CBC / 10-digit decimal words / custom tweak\nAesKey = \u003c\u003c43,126,21,22,40,174,210,166,171,247,21,136,9,207,79,60\u003e\u003e,\nValueLength = 10,\nConfig = erlffx:config(AesKey, ValueLength, #{ tweak =\u003e \"9876543210\" }).\n\nEncrypted = erlffx:encrypt(Config, 123456789). % 6124200773\nDecrypted = erlffx:decrypt(Config, Encrypted). % 123456789\n```\n\n-----\n\n``` erlang\n% AES-128 CBC / 16-digit base-36 words / custom tweak\nAesKey = \u003c\u003c43,126,21,22,40,174,210,166,171,247,21,136,9,207,79,60\u003e\u003e,\nValueLength = 16,\nConfig = erlffx:config(AesKey, ValueLength, #{ tweak =\u003e \"TQF9J5QDAGSCSPB1\", radix =\u003e 36 }).\n\nEncrypted = erlffx:encrypt(Config, 36#C4XPWULBM3M863JH). % 36#C8AQ3U846ZWH6QZP\nDecrypted = erlffx:decrypt(Config, Encrypted).           % 36#C4XPWULBM3M863JH\n```\n\n-----\n\n``` erlang\n% AES-256 CBC / 6-digit binary words\nAesKey = \u003c\u003c43,126,21,22,40,174,210,166,171,247,21,136,9,207,79,60,\n           239,67,89,216,213,128,170,79,127,3,109,111,4,252,106,148\u003e\u003e,\nValueLength = 6,\nConfig = erlffx:config(AesKey, ValueLength, #{ radix =\u003e 2 }).\n\nEncrypted = erlffx:encrypt(Config, 2#000001).  % 2#100100\nDecrypted = erlffx:decrypt(Config, Encrypted). % 2#000001\n```\n\n-----\n\n*Generated by EDoc*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg-andrade%2Ferlffx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fg-andrade%2Ferlffx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg-andrade%2Ferlffx/lists"}