Document 001: Mesmeria van Rensselaer’s Harddrive

Document 001: Mesmeria van Rensselaer’s Harddrive#

Important

The following files were extracted from an encrypted harddrive that was confiscated during the execution of a search warrant on the van Rensselaer estate in Albany, New York on January 1st, 2111.

/users/mrensselaer/lib/21st-century/ciphers.py#

# ==============================================================================
# DATE: 2105-09-12
# AUTHOR: M.v.R.
# ==============================================================================

def atbash(text):
    """
    Applies an elementary atbash cipher to the input text.
    """
    result = []

    for char in text:
        if char.isalpha():
            # Get the ASCII code
            code = ord(char)

            if char.isupper():
                # 'A' is 65, 'Z' is 90
                # Transformation: 155 - code
                result.append(chr(155 - code))
            else:
                # 'a' is 97, 'z' is 122
                # Transformation: 219 - code
                result.append(chr(219 - code))
        else:
            # Pass punctuation/numbers through untouched
            result.append(char)

    return "".join(result)

def main():
    print("ATBASH // VER 0.1a")
    print("INSTRUCTION: Paste the encrypted text (or text to encrypt).")
    print("INSTRUCTION: Type 'EXIT' to kill the process.\n")

    while True:
        try:
            user_input = input(">> INPUT: ")

            if user_input.strip().upper() == 'EXIT':
                break

            if not user_input:
                continue

            transformed = atbash(user_input)

            print(f"<< RESULT: {transformed}")
            print("-" * 40)

        except KeyboardInterrupt:
            print("[WARN] Manual interrupt detected. Aborting.")
            break
        except Exception as e:
            # Catch-all for whatever weird errors this archaic interpreter throws
            print(f"[ERROR] Logic fault: {e}")

if __name__ == "__main__":
    main()

/users/mrensselaer/lib/21st-century/sieve.py#

def _squares(n):
    """
    Arguments:
        n (int): arbitray integer

    Returns:
        a list of squares up to the value of ``n``.
    """

    return [
        i*i
        for i in range(1, n+1)
        if i*i < n
    ]

def primes(n):
    """
    Arguments:
        n (int): arbitrary integer
    Returns:
        A list of primes up to the values of ``n``
    """

    sqs = _squares(n)
    sieve = {
        x: True
        for x in range(2,n+1)
    }

    # NOTE: len(sqs) + 2 gives the next closest root of a perfect square
    for i in range(2, len(sqs) + 2):
        if sieve[i]:
            for j in range(1+1, n // i + 1):
                sieve[i*j] = False

    return [ k for k,v in sieve.items() if v ]

if __name__== "__main__":
    print(primes(300))