cyrildever / feistel Goto Github PK
View Code? Open in Web Editor NEWFeistel cipher implementation in Golang for format-preserving encryption
License: MIT License
Feistel cipher implementation in Golang for format-preserving encryption
License: MIT License
Wikipedia's definition of FPE as:
In cryptography, format-preserving encryption (FPE), refers to encrypting in such a way that the output (the ciphertext) is in the same format as the input (the plaintext). The meaning of "format" varies. Typically only finite sets of characters are used; numeric, alphabetic or alphanumeric. For example:
- Encrypting a 16-digit credit card number so that the ciphertext is another 16-digit number.
- Encrypting an English word so that the ciphertext is another English word.
- Encrypting an n-bit number so that the ciphertext is another n-bit number (this is the definition of an n-bit block cipher).
However, the result obtained by encrypting the original data with Encrypt() does not seem to be in the same format as the original data.
For example, the encrypted number 123123123123
, according to FPE
, what I get should be a string of pure numbers, but what I actually get is `ZW±ªX^²[[®R.
Did we just keep the same length?
source := "my-source-data"
cipher := feistel.NewFPECipher(hash.SHA_256, "some-32-byte-long-key-to-be-safe", 128)
obfuscated, err := cipher.Encrypt(source)
assert.NoError(t, err)
str := obfuscated.String()
fmt.Println(str)
assert.Equal(t, len(source), len(str))
Error: Not equal:
expected: 21
actual : 14
Test: TestFormatPreservingEncryption
MacOS 12.6 M1
github.com/cyrildever/feistel v1.3.21
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.