A
A
Andrew92052019-04-13 21:18:06
JavaScript
Andrew9205, 2019-04-13 21:18:06

How to implement encryption in js?

Hello.
I need to encrypt/decrypt a number.
For example, this is: 7801703542
The output should be a number of the same length, for example: 004521787
Are there libraries ready for this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Egorov, 2019-04-13
@Andrew9205

Here is a search for the tag on github - https://github.com/topics/format-preserving-encryp...
If anything, this is Encryption that preserves the
node-fpe format

const fpe = require('node-fpe');
const cipher = fpe({ password: 'secret' });

cipher.encrypt('1234567');
// '4185730'

cipher.decrypt('4185730');
// '1234567'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question