ecollect / node-fe1-fpe Goto Github PK
View Code? Open in Web Editor NEWNode.js implementation of the FE1 Format Preserving Encryption algorithm.
License: MIT License
Node.js implementation of the FE1 Format Preserving Encryption algorithm.
License: MIT License
Hi,
I see that currently it supports only numbers, is there a reason why ASCII alphabets and Unicode is not supported?
Thanks.
The calculation of left
in decryption can result in a negative number when modulu
is less than 0,
Line 63 in ceae15b
this leads to a failure to recover the original value.
The value produced should be based on - modulu
in all cases (to ensure a positive result):
left = (modulu > 0) ? firstFactor - modulu : - modulu;
You can confirm this change is an improvement by
expectedEV
assertions from the unit tests (tests should still pass with less assertions)format()
function to return ... % 100n
to force the modulu <= 0
case to occur, (tests now fail).Then remember to
format()
function.Should I expect to get the same encrypted result as what is shown in the README?
I get 5011
instead of 4984
:
$ node
Welcome to Node.js v12.14.1.
> const fe1 = require('node-fe1-fpe');
> const v = fe1.encrypt(10001, 1, 'my-secret-key', 'my-non-secret-tweak');
> console.log(v)
5011
> const d = fe1.decrypt(10001, v, 'my-secret-key', 'my-non-secret-tweak');
> console.log(d);
1
// curious what 4984 decrypts to:
> const d2 = fe1.decrypt(10001, 4984, 'my-secret-key', 'my-non-secret-tweak');
> console.log(d2);
6786
Hi, it looks like currently modulo is supported up to 10 000 000. But for 15-digit credit card, don't we need 10^15 modulo?
Hi, I noticed that the round is hard-coded, how about providing an optional round argument?
fwiw, botan also has round as an argument https://botan.randombit.net/manual/fpe.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.