R
R
ruboss2015-10-10 18:56:14
Java
ruboss, 2015-10-10 18:56:14

How to get shorter hash with Long?

Hello!
How can one compress (long) 4108660549 into a string of less than 10 characters?
Characters must be only latin, numbers.
For example:
4108660549 => "ghd1" is ideal.
Only at the same time it should be 2 ^ 32 without collisions

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2015-10-10
@ruboss

Convert to 62-decimal number system 0-9a-zA-Z.
The maximum length will be
log 62 (2 32 ) = 5.37 , which is 6 bits.
In a 36-character system, 0-9a-z will be 7 digits long.
4108660549 10 = 4u3wix 62 = 1vy6urp 36

R
ruboss, 2015-10-10
@ruboss

found - https://github.com/peet/hashids.java

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question