GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python-validity/validitysensor/sid.py at master · uunicorn/python-validity

Expand file tree

/

sid.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
45 lines (30 loc) · 1.06 KB
/

sid.py

Copy path

File metadata and controls

45 lines (30 loc) · 1.06 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import typing
from struct import unpack, pack
class SidIdentity:
def __init__(self, revision: int, auth: int, subauth: typing.Sequence[int]):
self.revision = revision
self.auth = auth
self.subauth = subauth
def to_bytes(self):
b = pack('>BBHL', self.revision, len(self.subauth), self.auth >> 32, self.auth & 0xffffffff)
for i in self.subauth:
b += pack('<L', i)
return b
def __repr__(self):
return 'S-%d-%d-%s' % (self.revision, self.auth, '-'.join(map(str, self.subauth)))
def sid_from_bytes(b: bytes):
revision = b[0]
subcnt = b[1]
auth = 0
for i in b[2:8]:
auth <<= 8
auth |= i
subauth = unpack('<%dL' % subcnt, b[8:])
return SidIdentity(revision, auth, subauth)
def sid_from_string(s: str):
parts = s.split('-')
if parts[0] != 'S':
raise Exception('Expected "S" as a first part')
parts = list(map(int, parts[1:]))
revision, auth, subauth = parts[0], parts[1], parts[2:]
return SidIdentity(revision, auth, subauth)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.