https://github.com/plotdb/obfidx
Obfuscator for 32 bit integer.
https://github.com/plotdb/obfidx
Last synced: 21 days ago
JSON representation
Obfuscator for 32 bit integer.
- Host: GitHub
- URL: https://github.com/plotdb/obfidx
- Owner: plotdb
- Created: 2022-01-29T09:59:28.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-29T10:33:18.000Z (about 4 years ago)
- Last Synced: 2025-02-26T08:35:23.634Z (about 1 year ago)
- Language: LiveScript
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# obfidx
Obfuscator for 32 bit integer to a base-51 string.
Based on a sample script from [Pseudo encrypt - Postgresql wiki](https://wiki.postgresql.org/wiki/Pseudo_encrypt), by Daniel Vérité and Jaka Jancar. The permutation property of this algorithm is a consequence of the function being a Feistel network; see [Feistel cipher](https://en.wikipedia.org/wiki/Feistel_cipher).
This function guarantees following property, within given range:
- output is uniquely associated to its integer input
- looks random
- zero collision
Additionally,
- it returns a signed integer (postgres doesn't have unsigned integers anyway).
- it's a self-inverse, that is: pseudo_encrypt(pseudo_encrypt(X)) = X
- the output may be customized by changing this function of r1
## Usage
include/require obfidx js and:
obfidx = obfidx a, b, c
obfuscated-number = obfidx original-number
where `a`, `b` and `c` are some casual numbers used in following function:
f = ((a * R1 + b ) % c ) / c
which guarantee a output value of `f(v)` in 0 ~ 1, and for any `x` = `y`, `f(x)` = `f(y)`.
## License
MIT