Work in progress to provide format-preserving encryption through the FF3-1 algorithm, a revised version of FF3 after security issues were uncovered.
I wrote this for the kicks - it is not a serious project.
key = <<
0xAD, 0x41, 0xEC, 0x5D, 0x23, 0x56, 0xDE, 0xAE,
0x53, 0xAE, 0x76, 0xF5, 0x0B, 0x4B, 0xA6, 0xD2
>>
tweak = <<0xCF, 0x29, 0xDA, 0x1E, 0x18, 0xD9, 0x70>>
{:ok, ctx} = FF3_1.new_ctx(key, 10)
assert "4716569208" == FF3_1.encrypt!(ctx, tweak, "6520935496")
assert "6520935496" == FF3_1.decrypt!(ctx, tweak, "4716569208")
If available in Hex, the package can be installed
by adding fpe
to your list of dependencies in mix.exs
:
def deps do
[
{:ff3_1, "~> 0.1.0"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/fpe.