diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-07-20 14:32:54 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-07-20 14:32:54 -0700 |
commit | e4c1514294443b9e6f6ed716dcad5ebec64c3af8 (patch) | |
tree | 4b2822526b63058a433483ed4b1cd73020be79aa /README.md | |
parent | 4144debb6c0317efcde3c97fc6d8b369c6530b6d (diff) | |
download | fatcat-e4c1514294443b9e6f6ed716dcad5ebec64c3af8.tar.gz fatcat-e4c1514294443b9e6f6ed716dcad5ebec64c3af8.zip |
prep for base32 encoded identifiers
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -46,3 +46,25 @@ database/API (but is useful for paper lookups). - [ ] Authentication (eg, accounts, OAuth2, JWT) - [ ] Authorization (aka, roles) - [ ] bot vs. editor + +## Identifiers + +Fatcat entity identifiers are in "boring" + +Python helpers for conversion: + + import base64 + import uuid + + def fcid2uuid(s): + s = s.split('_')[-1].upper().encode('utf-8') + assert len(s) == 26 + raw = base64.b32decode(s + b"======") + return str(uuid.UUID(bytes=raw)).lower() + + def uuid2fcid(s): + raw = uuid.UUID(s).bytes + return base64.b32encode(raw)[:26].lower().decode('utf-8') + + test_uuid = '00000000-0000-0000-3333-000000000001' + assert test_uuid == fcid2uuid(uuid2fcid(test_uuid)) |