-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import hashlib | ||
|
||
class CryptoModel: | ||
def __init__(self): | ||
pass | ||
|
||
def generate_key_pair(self) -> (str, str): | ||
# Generate a new key pair | ||
private_key = hashlib.sha256("private_key".encode()).hexdigest() | ||
public_key = hashlib.sha256("public_key".encode()).hexdigest() | ||
return private_key, public_key | ||
|
||
def encrypt(self, data: str, public_key: str) -> str: | ||
# Encrypt data using a public key | ||
encrypted_data = hashlib.sha256(f"{data}{public_key}".encode()).hexdigest() | ||
return encrypted_data | ||
|
||
def decrypt(self, encrypted_data: str, private_key: str) -> str: | ||
# Decrypt data using a private key | ||
decrypted_data = hashlib.sha256(f"{encrypted_data}{private_key}".encode()).hexdigest() | ||
return decrypted_data |