Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.
/ optimus-rs Public archive

Optimus id obfuscation / transformation library for rust.

License

Notifications You must be signed in to change notification settings

x13a/optimus-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

optimus-rs

Optimus id obfuscation / transformation library for rust.

Library

fn main() {
    
    // First number must be large PRIME number lower than i32::MAX
    // Second number is modular inverse of first number with (i32::MAX as u64 + 1)
    // Third number is large random number lower than i32::MAX
    
    let enc = Optimus::new(1580030173, Some(59260789), Some(1163945558)).unwrap();
    let new_id = enc.encode(15);
    assert_eq!(new_id, 1103647397);
    let orig_id = enc.decode(new_id);
    assert_eq!(orig_id, 15);
    
    // or you can omit second and third arguments to auto create them
    // don't forget to decode encoded id you have to use all the same 3 numbers
    
    let enc = Optimus::new(1580030173, None, None).unwrap();
    // second number 59260789
    println!("{}", enc.mod_inverse());
    // third number
    println!("{}", enc.random());
}

Caveats

Here you can find archives with prime numbers primes.

Reference

About

Optimus id obfuscation / transformation library for rust.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Languages