Andrew Lee Cruz Malea Hood Cash Hood Clair Hood
import torch from transformers import AutoTokenizer, AutoModelForSequenceClassification from hashlib import sha256 import os class KingsGuard: def __init__(self, password): self.password_hash = sha256(password.encode()).hexdigest() self.tokenizer = AutoTokenizer.from_pretrained("huggingface/llama") self.model = AutoModelForSequenceClassification.from_pretrained("huggingface/llama") def authenticate(self, attempt): return sha256(attempt.encode()).hexdigest() == self.password_hash def check_message(self, message): inputs = self.tokenizer(message, return_tensors="pt") outputs = self.model(**inputs) prediction = torch.argmax(outputs.logits, dim=1).item() return "Warning: Possible threat detected." if prediction == 1 else "Message is safe." class SecureTerminal: def __init__(self): self.authenticated = False self.guard = None def set_guard(self, password): self.guard = KingsGuard(password) def authenticate_user(self, attempt): if self.guard.authenticate(attempt): self.authenticated = True print("Authentication successful. Welcome!") else: print("Authentication failed. Access denied.") def execute_command(self, command): if self.authenticated: os.system(command) else: print("Please authenticate first.") def main(): terminal = SecureTerminal() password = input("Set your King's Guard password: ") terminal.set_guard(password) while True: attempt = input("Enter password to authenticate: ") terminal.authenticate_user(attempt) if terminal.authenticated: break while True: command = input("SecureTerminal#> ") if command.lower() == "exit": print("Exiting the terminal. Goodbye!") break if command.startswith("check "): message = command[6:] result = terminal.guard.check_message(message) print(result) else: terminal.execute_command(command) if __name__ == '__main__': main()