SecureBase
ProjectsLibrariesQuick LinksFeedback
English
English
  • SecureBase
    • Demo Apps Screenshots
  • .NET
    • Installation
    • Usage
    • Version Notes
  • Delphi
    • Installation
    • Usage
    • Version Notes
  • Go
    • Installation
    • Usage
    • Version Notes
  • Java
    • Installation
    • Usage
    • Version Notes
  • Python
    • Installation
    • Usage
    • Version Notes
Powered by GitBook
On this page
  1. Python

Usage

PreviousInstallationNextVersion Notes

Last updated 6 months ago

CtrlK
from SecureBase import SecureBase, SBEncoding
#enc = SBEncoding.UNICODE
enc = SBEncoding.UTF8
sb = SecureBase(encoding=enc)
sb.set_secret_key("set-secret-key")

#Text to Base64
encoded = sb.encode(inputdata)

#Base64 to Text
decoded = sb.decode(inputdata)
from SecureBase import SecureBase, SBEncoding

sb = SecureBase(encoding=SBEncoding.UTF8)
sb.set_secret_key("SET-SECRET-KEY")

try:
    with open("data.txt", "r", encoding="utf-8") as file:
        content = file.read()
        file.close()
    encoded = sb.encode(content)
    with open("encoded.txt", "w") as fw:
        fw.write(sb.encode(content))
        fw.close()
    with open("decoded.txt", "w") as fw:
        fw.write(sb.decode(encoded))
        fw.close()
except Exception as e:
    print(f"!: {e}")

You can examine sample usage via the SecureBaseApp application on Github.