aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-07-20 14:32:54 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-07-20 14:32:54 -0700
commite4c1514294443b9e6f6ed716dcad5ebec64c3af8 (patch)
tree4b2822526b63058a433483ed4b1cd73020be79aa /README.md
parent4144debb6c0317efcde3c97fc6d8b369c6530b6d (diff)
downloadfatcat-e4c1514294443b9e6f6ed716dcad5ebec64c3af8.tar.gz
fatcat-e4c1514294443b9e6f6ed716dcad5ebec64c3af8.zip
prep for base32 encoded identifiers
Diffstat (limited to 'README.md')
-rw-r--r--README.md22
1 files changed, 22 insertions, 0 deletions
diff --git a/README.md b/README.md
index 239e69a2..a17a3458 100644
--- a/README.md
+++ b/README.md
@@ -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))