aboutsummaryrefslogtreecommitdiffstats
path: root/notes
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-04 13:31:37 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-04 13:31:37 -0800
commitc1cdda4cf4c714f92b5fd7676e44ab5a92e637a9 (patch)
tree4aff5501710d35636fe35587b0ed6816d4b7dbd7 /notes
parent3aee89745355b0ced5223c601a03f77e46d997dc (diff)
downloadfatcat-c1cdda4cf4c714f92b5fd7676e44ab5a92e637a9.tar.gz
fatcat-c1cdda4cf4c714f92b5fd7676e44ab5a92e637a9.zip
update main README
Diffstat (limited to 'notes')
-rw-r--r--notes/fatcat_idents.md25
1 files changed, 25 insertions, 0 deletions
diff --git a/notes/fatcat_idents.md b/notes/fatcat_idents.md
new file mode 100644
index 00000000..84322604
--- /dev/null
+++ b/notes/fatcat_idents.md
@@ -0,0 +1,25 @@
+
+## Identifiers
+
+Fatcat entity identifiers are 128-bit UUIDs encoded in base32 format. Revision
+ids are also UUIDs, and encoded in normal UUID fashion, to disambiguate from
+edity identifiers.
+
+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))
+