🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

optimus-ts

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

optimus-ts

With this library, you can transform your ids to obfuscated integers based on Knuth's integer hash. Port of optimus-js

1.0.1
latest
Source
npm
Version published
Maintainers
1
Created
Source

NPM Version Travis Info

optimus-ts

With this library, you can transform your ids to obfuscated integers based on Knuth's integer hash. Port of optimus-js https://www.npmjs.com/package/optimus-js

Installation

npm i optimus-ts
yarn add optimus-ts

Usage

To initialize the library you need 3 things.

  • Large prime number lower than 2147483647 (prime)
  • The inverse prime so that (prime * inverse) & 2147483647 = 1
  • A large random number lower than 2147483647

For more info refer to the original project

using the above parameters you can create instances of Optimus(prime, inverse, random)

import Optimus from 'optimus-ts'

let optimus = new Optimus(1580030173, 59260789, 1163945558)

After that you can use encode and decode methods to encode/decode positive integers ranging from (0 to 2147483647).

let hash = optimus.encode(25);
let original = optimus.decode(hash);

Warning: Please note that this library only provides obfuscation and not encryption.

Keywords

optimus

FAQs

Package last updated on 25 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts