Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions examples/fastapi/main.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from fastapi import FastAPI
from dotzen import config
# from fastapi import FastAPI
# from dotzen import config

app = FastAPI()
# app = FastAPI()

SECRET_KEY = config("SECRET_KEY", default="key")
# SECRET_KEY = config("SECRET_KEY", default="key")

@app.get("/")
def get_home():
return {
"secret-key": SECRET_KEY
}
# @app.get("/")
# def get_home():
# return {
# "secret-key": SECRET_KEY
# }
22 changes: 11 additions & 11 deletions examples/flask/app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from flask import Flask
from dotzen import config
# from flask import Flask
# from dotzen import config

app = Flask(__name__)
# app = Flask(__name__)

SECRET_KEY = config("SECRET_KEY", default="key")
# SECRET_KEY = config("SECRET_KEY", default="key")

@app.route("/")
def get_home():
return {
"secret-key": SECRET_KEY
}
# @app.route("/")
# def get_home():
# return {
# "secret-key": SECRET_KEY
# }


if __name__ == "__main__":
app.run()
# if __name__ == "__main__":
# app.run()
56 changes: 28 additions & 28 deletions examples/general/main.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
from dotzen import EncryptionManager
from dotzen.encryption import encrypt_for_env
# from dotzen import EncryptionManager
# from dotzen.encryption import encrypt_for_env


if __name__ == "__main__":
# Demo usage
print("=== DotZen Encryption Demo ===\n")
# if __name__ == "__main__":
# # Demo usage
# print("=== DotZen Encryption Demo ===\n")

# Base64 encryption
print("1. Base64 Encryption:")
original = "carrington"
encrypted = EncryptionManager.encrypt(original, 'base64')
decrypted = EncryptionManager.decrypt(encrypted, 'base64')
print(f"Original: {original}")
print(f"Encrypted: {encrypted}")
print(f"Decrypted: {decrypted}")
print()
# # Base64 encryption
# print("1. Base64 Encryption:")
# original = "carrington"
# encrypted = EncryptionManager.encrypt(original, 'base64')
# decrypted = EncryptionManager.decrypt(encrypted, 'base64')
# print(f"Original: {original}")
# print(f"Encrypted: {encrypted}")
# print(f"Decrypted: {decrypted}")
# print()

# MD5 hashing (one-way)
print("2. MD5 Hashing (one-way):")
hashed = EncryptionManager.encrypt("password123", 'md5')
print(f"Hashed: {hashed}")
print()
# # MD5 hashing (one-way)
# print("2. MD5 Hashing (one-way):")
# hashed = EncryptionManager.encrypt("password123", 'md5')
# print(f"Hashed: {hashed}")
# print()

# SHA256 hashing (one-way)
print("3. SHA256 Hashing (one-way):")
hashed = EncryptionManager.encrypt("password123", 'sha256')
print(f"Hashed: {hashed}")
print()
# # SHA256 hashing (one-way)
# print("3. SHA256 Hashing (one-way):")
# hashed = EncryptionManager.encrypt("password123", 'sha256')
# print(f"Hashed: {hashed}")
# print()

# Encrypt for .env file
print("4. Encrypt for .env file:")
env_value = encrypt_for_env("my-super-secret-api-key")
print(f"Add to .env: API_KEY={env_value}")
# # Encrypt for .env file
# print("4. Encrypt for .env file:")
# env_value = encrypt_for_env("my-super-secret-api-key")
# print(f"Add to .env: API_KEY={env_value}")
Loading