diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-08 16:28:27 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-08 16:28:27 -0800 |
commit | 16f2e78298dbd2231f5f337ea17c89a6a131a052 (patch) | |
tree | 6e72581e625e73c97cbab72d0f9c35665c99e5d7 /notes/fatcat_idents.md | |
parent | eb40a5f274f3608db34309cfd16739a7642ef5e7 (diff) | |
parent | ffb721f90c5d97ee80885209bf45feb85ca9625c (diff) | |
download | fatcat-16f2e78298dbd2231f5f337ea17c89a6a131a052.tar.gz fatcat-16f2e78298dbd2231f5f337ea17c89a6a131a052.zip |
Merge branch 'bnewbold-crude-auth'
Fixed a conflict in:
python/fatcat_export.py
Diffstat (limited to 'notes/fatcat_idents.md')
-rw-r--r-- | notes/fatcat_idents.md | 25 |
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)) + |