-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generated number length? #15
Comments
I'm interested also to this. Is it possible to generate fixed length numbers or at least know the length of the number in terms of range? |
@mtangoo I actually created my own library for this loostro/cryptomute - an implementation of Format Preserving Encryption based on Feistel Ciphers. |
The maximum value is controlled by the But you could try extending the class and overwriting the MAX_INT value. |
Could you also elaborate on the use case? |
Suppose you generate something like Student ID. You want all student IDs to have same length in digits despite their real IDs. Another example might be a bank account |
@loostro |
@mtangoo no, there will be none. Read on Formart Preserving Encryption |
@loostro thanks. |
You may do:
|
any updates on this? |
PR #36 introduces flexibility around this. Note that from what I could see, the maths for generating the integers requires a binary numbers. This means you could restrict the numbers to 65535 but not 99999. For anyone who desperately needs more flexibility, a similar strategy is described at A practical use of multiplicative inverses which uses Modulus rather than a Bitwise And to shift the value. I found in testing that this method allows any int to be used as a max. However it also requires the use of co-prime rather than a prime. So the strategy is not compatible with Optimus. |
Is it possible to control the generated number length?
Eg. say I need 7-digits unique numbers, generated based on some integer eg.
?
The text was updated successfully, but these errors were encountered: