Using Hashids with strings

2.1k Views Asked by At

I looking for a way to generate a short, unique, immutable and reversible ID from an original string. I found the perfect library Hashids for that but it only wants integer in input, and I also have letters.

I don't want to use common encryption algorithms because the output is very long.

I can achieve that with base64_encode but I want to hash with a passphrase to prevent direct decoding from unwanted people.

Anyone know a solution?

1

There are 1 best solutions below

3
On

I don't think you found the "perfect library" for your needs. From the website;

Do not encode strings. We've had several requests to add this feature — "it seems so easy to add". We will not add this feature for security purposes, doing so encourages people to encode sensitive data, like passwords. This is the wrong tool for that.