Federico Liva
Federico Liva

Reputation: 578

Using Hashids with strings

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?

Upvotes: 2

Views: 2291

Answers (1)

ullmark
ullmark

Reputation: 96

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.

Upvotes: 1

Related Questions