Spaces:
Sleeping
Sleeping
File size: 4,793 Bytes
68603c0 d8a5c78 68603c0 ff16f1e d8a5c78 68603c0 d8a5c78 68603c0 d8a5c78 68603c0 d8a5c78 68603c0 d8a5c78 68603c0 d8a5c78 68603c0 d8a5c78 68603c0 d8a5c78 68603c0 d8a5c78 68603c0 d8a5c78 68603c0 33a63dc d8a5c78 33a63dc d8a5c78 33a63dc d8a5c78 33a63dc d8a5c78 33a63dc d8a5c78 33a63dc d8a5c78 33a63dc d8a5c78 33a63dc d8a5c78 33a63dc d8a5c78 33a63dc d8a5c78 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
import streamlit as st
import os
import random
import base64
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
# --- Sentinel Engine Functions ---
def generate_key(seed: str, dimensions: int = 5):
"""Sentinel multi-dimensional key derivation"""
kdf = PBKDF2HMAC(
algorithm=hashes.SHA256(),
length=32,
salt=b'sentinel_salt', # change to a secure static salt or dynamic
iterations=200000, # higher iterations for quantum resilience
backend=default_backend()
)
key = kdf.derive(seed.encode())
# Multi-dimensional expansion (adaptive randomness)
key += bytes([random.randint(0, 255) for _ in range(dimensions * 16)])
return key[:32]
def encrypt_data(data: bytes, key: bytes) -> bytes:
iv = os.urandom(16) # cryptographically secure IV
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=default_backend())
encryptor = cipher.encryptor()
padding_len = 16 - len(data) % 16
data += bytes([padding_len] * padding_len)
encrypted = encryptor.update(data) + encryptor.finalize()
return iv + encrypted
def decrypt_data(encrypted_data: bytes, key: bytes) -> bytes:
iv = encrypted_data[:16]
encrypted_data = encrypted_data[16:]
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=default_backend())
decryptor = cipher.decryptor()
decrypted = decryptor.update(encrypted_data) + decryptor.finalize()
padding_len = decrypted[-1]
return decrypted[:-padding_len]
# --- Streamlit UI ---
# Display Logo
st.image(
"https://huggingface.co/spaces/taarhissian/SentinelCryptography/resolve/main/sentinelcryptography.png",
caption="SentinelCryptography Logo",
use_container_width=True
)
st.title("π‘ SentinelCryptography")
st.subheader("A Quantum-Ready Encryption Guardian")
st.write("""
SentinelCryptography is not just an AES tool β it is a living sentinel, designed to protect your messages
today and withstand the cryptographic challenges of tomorrow.
""")
# --- Session State for Seed ---
if "seed" not in st.session_state:
st.session_state.seed = ""
# --- Encryption Section ---
st.markdown("---")
st.header("π Encrypt a Message")
message = st.text_area("Enter Message to Encrypt:")
st.session_state.seed = st.text_input("Enter Seed/Password for Key Generation:", st.session_state.seed)
if st.button("Encrypt"):
if message and st.session_state.seed:
key = generate_key(st.session_state.seed, dimensions=5)
encrypted = encrypt_data(message.encode(), key)
st.success("β
Encryption Complete!")
st.code(base64.b64encode(encrypted).decode(), language="text")
else:
st.error("Please enter both a message and a seed/password.")
# --- Decryption Section ---
st.markdown("---")
st.header("π Decrypt a Message")
encrypted_input = st.text_area("Enter Encrypted Message (Base64):")
if st.button("Decrypt"):
if encrypted_input and st.session_state.seed:
try:
encrypted_bytes = base64.b64decode(encrypted_input)
key = generate_key(st.session_state.seed, dimensions=5)
decrypted = decrypt_data(encrypted_bytes, key)
st.success("β
Decryption Complete!")
st.code(decrypted.decode(), language="text")
except Exception as e:
st.error(f"Decryption failed: {e}")
else:
st.error("Please enter both an encrypted message and the seed/password.")
# --- Educational & Roadmap Sections ---
st.markdown("---")
st.header("π The Legacy of Encryption")
st.write("""
Encryption has evolved from ancient substitution ciphers to mechanical rotors in WWII,
and finally to AES in the modern era. SentinelCryptography pushes this evolution further,
preparing for the quantum era.
""")
st.markdown("---")
st.header("π Roadmap for 2025")
st.write("""
1. Q1: Expand post-quantum cryptographic support.
2. Q2: APIs for web & mobile integration.
3. Q3: Community challenges to improve security.
4. Q4: Launch full SentinelCryptography platform with analytics and advanced features.
""")
st.image("https://via.placeholder.com/800x400.png?text=SentinelCryptography+2025+Roadmap")
# --- Donation Section ---
st.markdown("---")
st.header("π Support SentinelCryptography")
st.write("""
Your donations help us continue development and keep this project open source.
**Donate via Tether (USDT-ERC20)**: `0xD5255523b1A6a144D9d034c70735b2dB729B49f0`
Every contribution empowers global security for the quantum era.
""")
st.info("SentinelCryptography is open source. Together, we secure the future.") |