3 ms·
One of the nice little features that I appreciate about Twilio, and have adopted myself, is their API keys are always prefixed with a 2 character type. e.g. "
by grouseway 8y ago
One of the nice little features that I appreciate about Twilio, and have adopted myself, is their API keys are always prefixed with a 2 character type.
e.g.
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"phone_number_sid": "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"sid": "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
- jerf 8y agoHard-won pro-tip: IDs should pretty much always have some sort of prefix when stored as strings, even if you swear you're never going to change them. You're not going to want to try to divine which id was which based on string length or what chars are where later. I qualify "when stored as strings" because id numbers in database rows are in a sufficiently strong context on their own, for instance. But once they get serialized to strings, you really ought to stick a prefix on them. You may only change 10% of your ids, but the saving on that 10% will be well worth the cost of prefixing your ids.
- ex3ndr 8y agoBut why this doesn't needed if you use numerical ids?
- cbhl 8y agoIf you work on a sufficiently long lived system, you also discover that you usually want string ids instead of numerical ids. Among other things, numerical ids are subject to enumeration attack (especially if exposed in a GET url parameters).
- cure 8y agoYeah, we do this too in Arvados (https://arvados.org https://arvados.org). All our uuids consist of three parts separated by a hyphen. The first part denotes the cluster, the middle part denotes the type of object, and the last part is a random string. E.g. qr1hi-j7d0g-a68mg4e5oh37oek where 'qr1hi' is the cluster identifier, 'j7d0g' means 'project', and 'a68mg4e5oh37oek' is a unique identifier.