CAT-SOOP API: catsoop.util

Extra utilities that don't have a home anywhere else

View Source

Members

  • catsoop.util.catsoop_loc_hash (function, lines 82-88)

    Function to generate a hash representative of this catsoop instance (by hashing cs_url_root). Used to generate names for the session ID, to be used when setting cookies.

 

  • catsoop.util.literal_eval (function, lines 103-165)

    Helper function to read a log entry and return the associated Python object. Forked from Python 3.5's ast.literal_eval function:

    Safely evaluate an expression node or a string containing a Python expression. The string or node provided may only consist of the following Python literal structures: strings, bytes, numbers, tuples, lists, dicts, sets, booleans, and None.

 

  • catsoop.util.simple_decrypt (function, lines 64-79)

    Decrypt the given ciphertext with the given key, using libsodium's secretbox construct

    Parameters:

    • key (bytes): a length-32 bytestring containing the encryption key
    • cipher (bytes): a bytestring containing the ciphertext (with 24-byte nonce prepended), of the form returned by simple_encrypt

    Returns: a bytestring containing the plaintext result of decrypting the given input

 

  • catsoop.util.simple_encrypt (function, lines 45-61)

    Encrypt the given plaintext string with the given key using libsodium's secretbox construct

    Parameters:

    • key (bytes): a length-32 bytestring containing the encryption key
    • msg (bytes): a bytestring of arbitrary length, containing the message to be encrypted

    Returns: a bytestring containing the resulting ciphertext, with the 24-byte nonce preprended