J
J
Jorik_Wa2017-11-29 19:46:15
Character encoding
Jorik_Wa, 2017-11-29 19:46:15

How to convert id in int64 to id with 11-12 characters?

The database stores id - int64. I want to have an id in the url on the UI in the format "8STmsLOBdgU", that is, like on youtube.
I want to store additionally this long id. That is, I want to encode / decode on the fly.
How to encode/decode id int64 into id in "8STmsLOBdgU" format? That is, 11-12 characters. What algorithm or crypto function to use?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Taratin, 2017-11-29
@Taraflex

https://de.wikipedia.org/wiki/Base62
https://en.wikipedia.org/wiki/Base58
The second one is more human friendly.
A ready-made encoder is not a problem to find for any popular language.

T
t38c3j, 2017-11-29
@t38c3j

hashids.org

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question