0

Exposing primary keys is bad practice. How should I expose UUID or BIGSERIAL Primary Keys to clients — hashing, encoding, encrypting? For integers there are libraries like hashids, what about UUID?

1

UUIDs are just large integers written in a particular format. There are libraries that convert to and fro UUIDs, or you can check out answers such as this.

Once you have the integer, you can employ AES, or some reversible scheme such as a Feistel network or, if the user has no way of ever recovering the decrypted information, a simple XOR with a known secret.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.