Skip to content
View psblah's full-sized avatar

Block or report psblah

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Content in all repositories owned by your account will be closed.
Maximum 250 characters. Please don’t include any personal information such as legal names or email addresses. This note will only be visible to you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
psblah/README.md

Hi there πŸ‘‹

 ___     ___     ____      _           ___      _    _
|    |  /  ___|  |  _ \   | |         /   |    | |  | |
| /| |  \ `--.   | |_) |  | |        / /| |    | |__| |
| ___|   `--. \  |  _ <   | |       / / | |    |  __  |
| |     /\__/    | |_) |  | |___   /  ___ |    | |  | |
|_|     \____/   |____/   |_____|  \/  |_|     |_|  |_|
import os
import hashlib

# ─── the entombed residue ────────────────────────────────────────────────
_Ξ© = 0x5a0f97d7dc14b54ae798048d5599dddc0053f16ff93e11a7db1c78965535ac0f129c00c95637a43da2f0e0b2d54b9cd04a32b7059ec45ad9618bf1c45ea2f97258f579c9c315e730a03c3e5426c9f8bc231a267b66913e84db2af9e169d6261e9d41d5136e6d
_Ξ› = 819            # exact bit-length of the residue
_Ξ£ = "a0d6c7136a9598d910bf00f6d297f5c04af277c6b3a2ee8a5164caaf1038ca40"  
_Ξ¦ = 0x9E3779B97F4A7C15    # βŒŠΟ†Β·2βΆβ΄βŒ‹ β€” the keystream germ
_΀ = 0xD800000000000000    # taps of x⁢⁴+x⁢³+x⁢¹+x⁢⁰+1 (maximal period)


def _keystream(Οƒ=_Ξ¦):
    while True:
        yield Οƒ & 1
        Οƒ = (Οƒ >> 1) ^ (-(Οƒ & 1) & _Ξ€)


class _Scry:
    __slots__ = ("_ptr",)

    def __init__(self):
        self._ptr = 0

    def __matmul__(self, n):
        if self._ptr + n > _Ξ›:
            raise EOFError("scried past the edge of the residue")
        v = (_Ξ© >> (_Ξ› - self._ptr - n)) & ((1 << n) - 1)
        self._ptr += n
        return v


def _spin(thunk):
    while callable(thunk):
        thunk = thunk()
    return thunk


class _Rite(type):
    def __new__(mcls, name, bases, ns):
        cls = super().__new__(mcls, name, bases, ns)
        cls._corpus = mcls._exhume()
        if hashlib.sha256(cls._corpus).hexdigest() != _Ξ£:
            raise RuntimeError("the seal is broken; these glyphs are lies")
        return cls

    @staticmethod
    def _exhume():
        s = _Scry()

        P = s @ 8
        palette = bytes(s @ 7 for _ in range(P))
        lens = [s @ 4 for _ in range(P)]
        N = s @ 20

 
        M = 0
        for l in lens:
            M = l if l > M else M
        cnt = [0] * (M + 1)
        for l in lens:
            cnt[l] += 1
        first = [0] * (M + 1)
        index = [0] * (M + 1)
        c = t = 0
        for l in range(1, M + 1):
            c = (c + cnt[l - 1]) << 1
            t += cnt[l - 1]
            first[l] = c
            index[l] = t

        ks = _keystream()
        out = bytearray()

        def step(code, l, got):
            if got == N:
                return bytes(out)
            code = (code << 1) | ((s @ 1) ^ next(ks))
            l += 1
            if l <= M and cnt[l] and first[l] <= code < first[l] + cnt[l]:
                out.append(palette[index[l] + code - first[l]])
                return lambda: step(0, 0, got + 1)
            if l > M:
                raise RuntimeError("wandered off the edge of the tree")
            return lambda: step(code, l, got)

        return _spin(lambda: step(0, 0, 0))


class Sigil(metaclass=_Rite):
    __slots__ = ()

    def __call__(self):
        os.write(1, type(self)._corpus)


if __name__ == "__main__":
    Sigil()()

Popular repositories Loading

  1. smartplayer smartplayer Public

    smartplayer

  2. CryptoCurrencyTrader CryptoCurrencyTrader Public

    Forked from johndpope/CryptoCurrencyTrader

    A machine learning program in python to generate cryptocurrency trading strategies using machine and deep learning on price, hash rate and scraped forum sentiment data (using natural language proce…

    Python

  3. Temp-Monitor Temp-Monitor Public

    Forked from ssimunic/Temp-Monitor

    Internet of Things data platform for temperature and humidity sensors with maps

    PHP

  4. rpi-security-system rpi-security-system Public

    Forked from ian-whitestone/rpi-security-system

    Building a home security system with a raspberry pi + Python + Slack

    Python

  5. helm-charts helm-charts Public

    Forked from codecentric/helm-charts

    A curated set of Helm charts brought to you by codecentric

    HTML

  6. psblah psblah Public

    Python