Exemplo n.º 1
0
def get_encrpyted_path(original_path, surfix=default_surfix):
    """
    Find the output encrypted file /dir path (by adding a surfix).

    Example:

    - file: ``${home}/test.txt`` -> ``${home}/test-encrypted.txt``
    - dir: ``${home}/Documents`` -> ``${home}/Documents-encrypted``
    """
    p = Path(original_path).absolute()
    encrypted_p = p.change(new_fname=p.fname + surfix)
    return encrypted_p.abspath
Exemplo n.º 2
0
def get_decrpyted_path(encrypted_path, surfix=default_surfix):
    """
    Find the original path of encrypted file or dir.

    Example:

    - file: ``${home}/test-encrypted.txt`` -> ``${home}/test.txt``
    - dir: ``${home}/Documents-encrypted`` -> ``${home}/Documents``
    """
    surfix_reversed = surfix[::-1]

    p = Path(encrypted_path).absolute()
    fname = p.fname
    fname_reversed = fname[::-1]
    new_fname = fname_reversed.replace(surfix_reversed, "", 1)[::-1]
    decrypted_p = p.change(new_fname=new_fname)
    return decrypted_p.abspath