Python Encryption

Python Encryption

Python shows up in data science, Django and Flask APIs, automation glue, and one-off scripts on shared servers. Source is usually deployed as readable .py files or tucked inside packages—no compile step to hide strings by default. That simplicity is why people love it; it also means secrets in source are one cat away.

Database passwords, third-party API tokens, and internal base URLs often end up hard-coded during a hurry. StringEncrypt gives you Python that rebuilds the string at runtime so a casual peek at the repo or the deployed tree is less informative.

String encryption supports both UNICODE and ANSI strings.

You can read more about Python and Python strings at:

Python encryption (UNICODE Example)

Plaintext reference: StringEncrypt sample

# encrypted with https://www.stringencrypt.com (v1.5.0) [Python]
# -*- coding: utf-8 -*-
# myString = "StringEncrypt sample"
myString = [0x2B76, 0xE1F1, 0x952C, 0xB16C, 0x530B, 0x5CC3, 0x8B27, 0xA439,
            0x06BF, 0xA9C0, 0xB651, 0x2A3C, 0xFBBA, 0x81E8, 0x44A8, 0x7B3B,
            0xB116, 0xF663, 0x7519, 0x078D]

for VXYhO in range(20):
    cRzuZ = myString[VXYhO]
    for xeWkI in range(3):
        cRzuZ = ((cRzuZ & 0xFFFF) - VXYhO) & 0xFFFF
        cRzuZ = (((cRzuZ & 0xFFFF) << (VXYhO % 16)) | ((cRzuZ & 0xFFFF) >> (16 - (VXYhO % 16)))) & 0xFFFF
    cRzuZ = (cRzuZ ^ (((cRzuZ & 0xFFFF) << 8) & 0xFFFF)) & 0xFFFF
    cRzuZ = (((~(cRzuZ & 0xFFFF)) & 0xFFFF) + 1) & 0xFFFF
    cRzuZ = (cRzuZ ^ 0x44F2) & 0xFFFF
    cRzuZ = ((cRzuZ & 0xFFFF) + VXYhO) & 0xFFFF
    cRzuZ = (((cRzuZ & 0xFFFF) << 6) | ((cRzuZ & 0xFFFF) >> 10)) & 0xFFFF
    cRzuZ = (cRzuZ ^ (((cRzuZ & 0xFFFF) << 13) & 0xFFFF)) & 0xFFFF
    for ihHDt in range(2):
        cRzuZ = (((cRzuZ & 0xFFFF) >> 8) | ((cRzuZ & 0xFFFF) << 8)) & 0xFFFF
        cRzuZ = (((cRzuZ & 0xFFFF) << (VXYhO % 16)) | ((cRzuZ & 0xFFFF) >> (16 - (VXYhO % 16)))) & 0xFFFF
        cRzuZ = (((cRzuZ & 0xFFFF) << 2) | ((cRzuZ & 0xFFFF) >> 14)) & 0xFFFF
    cRzuZ = ((cRzuZ & 0xFFFF) - 0x3D3F) & 0xFFFF
    for PJMSd in range(2):
        cRzuZ = (cRzuZ ^ VXYhO) & 0xFFFF
        cRzuZ = (((~(cRzuZ & 0xFFFF)) & 0xFFFF) + 1) & 0xFFFF
    for lwoUV in range(4):
        for oLyXu in range(4):
            for OsexT in range(4):
                cRzuZ = (cRzuZ ^ 0xFFFF) & 0xFFFF
            for ZThHi in range(3):
                cRzuZ = ((cRzuZ & 0xFFFF) + 0xD52B) & 0xFFFF
            cRzuZ = (cRzuZ ^ ((cRzuZ & 0xFFFF) >> 12)) & 0xFFFF
        cRzuZ = ((cRzuZ & 0xFFFF) - VXYhO) & 0xFFFF
    cRzuZ = (((~(cRzuZ & 0xFFFF)) & 0xFFFF) + 1) & 0xFFFF
    cRzuZ = ((cRzuZ & 0xFFFF) + 0x9EBB) & 0xFFFF
    myString[VXYhO] = cRzuZ

myString = ''.join(chr(cRzuZ & 0xFFFF) for cRzuZ in myString)

del VXYhO, cRzuZ

Python encryption (ANSI Example)

Plaintext reference: StringEncrypt sample

# encrypted with https://www.stringencrypt.com (v1.5.0) [Python]
# -*- coding: utf-8 -*-
# myString = "StringEncrypt sample"
myString = [0xF4, 0x4F, 0xB8, 0x51, 0xF2, 0x80, 0xC5, 0x77,
            0x6C, 0xBE, 0x85, 0x3B, 0xCA, 0xE9, 0xF8, 0x86,
            0x09, 0x74, 0xC0, 0xF7]

for sxHBF in range(20):
    lszai = myString[sxHBF]
    for RvfBK in range(4):
        for ibhsF in range(4):
            for RcweV in range(3):
                lszai = ((lszai & 0xFF) - 1) & 0xFF
            lszai = ((lszai & 0xFF) - 0x4A) & 0xFF
            lszai = (lszai ^ ((lszai & 0xFF) >> 7)) & 0xFF
    for cCnKX in range(3):
        for pCEGd in range(3):
            lszai = (lszai ^ 0xF3) & 0xFF
            lszai = (((lszai & 0xFF) >> 4) | ((lszai & 0xFF) << 4)) & 0xFF
        for zkoIN in range(4):
            for wyVpZ in range(3):
                lszai = ((lszai & 0xFF) + 1) & 0xFF
                lszai = ((lszai & 0xFF) - 1) & 0xFF
                lszai = (((lszai & 0xFF) >> 4) | ((lszai & 0xFF) << 4)) & 0xFF
            lszai = (lszai ^ 0x34) & 0xFF
    for tnOoE in range(4):
        lszai = (((lszai & 0xFF) >> 2) | ((lszai & 0xFF) << 6)) & 0xFF
        lszai = ((lszai & 0xFF) - 0x27) & 0xFF
    lszai = (lszai ^ sxHBF) & 0xFF
    lszai = ((lszai & 0xFF) + 0xCD) & 0xFF
    for gdoPR in range(4):
        for BSfMP in range(3):
            lszai = (lszai ^ (((lszai & 0xFF) << 4) & 0xFF)) & 0xFF
            for IbPjE in range(3):
                lszai = ((lszai & 0xFF) + 1) & 0xFF
            lszai = (lszai ^ ((lszai & 0xFF) >> 7)) & 0xFF
        for KwBHV in range(3):
            for Trmbx in range(2):
                lszai = (((lszai & 0xFF) >> 4) | ((lszai & 0xFF) << 4)) & 0xFF
                lszai = ((lszai & 0xFF) - 0x3A) & 0xFF
        for sHonU in range(3):
            lszai = (lszai ^ 0xFF) & 0xFF
            lszai = ((lszai & 0xFF) - 0x78) & 0xFF
    lszai = (((lszai & 0xFF) >> (sxHBF % 8)) | ((lszai & 0xFF) << (8 - (sxHBF % 8)))) & 0xFF
    for DiHYn in range(2):
        for YyqFO in range(4):
            lszai = (lszai ^ sxHBF) & 0xFF
        for PZFpy in range(4):
            lszai = ((lszai & 0xFF) + 0xB7) & 0xFF
            lszai = ((lszai & 0xFF) - 1) & 0xFF
            lszai = (((lszai & 0xFF) >> 1) | ((lszai & 0xFF) << 7)) & 0xFF
    lszai = ((lszai & 0xFF) + 0xB4) & 0xFF
    lszai = (((lszai & 0xFF) << (sxHBF % 8)) | ((lszai & 0xFF) >> (8 - (sxHBF % 8)))) & 0xFF
    myString[sxHBF] = lszai

myString = ''.join(chr(lszai & 0xFF) for lszai in myString)

del sxHBF, lszai