-
Notifications
You must be signed in to change notification settings - Fork 0
/
password_encryption.py
46 lines (35 loc) · 1.21 KB
/
password_encryption.py
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
import sys
import os
def encrypt(key, msg):
"""
Encrypts a message using a simple Caesar cipher.
Parameters:
- key (str): The encryption key.
- msg (str): The message to be encrypted.
Returns:
- str: The encrypted message.
"""
encrypted = [chr((ord(c) + ord(key[i % len(key)])) % 127) for i, c in enumerate(msg)]
return ''.join(encrypted)
def main():
"""
Main function to take user input, encrypt the Oracle DB password, and print the results.
"""
# Get the current working directory
pwd = os.getcwd()
# Prompt the user for the Oracle DB password
msg = raw_input("Please enter the Oracle DB password to be encrypted: ")
# Check if the entered password is empty
if msg == "":
print("Please provide a valid password as input.")
sys.exit()
# Encryption key for the Caesar cipher
key = "password encryption"
# Encrypt the password
encrypted = encrypt(key, msg)
# Print the original and encrypted passwords
print('Password To Be Encrypted:', str(msg))
print('Encrypted:', str(encrypted))
print("Please keep this password in config.ini file along with special characters.")
if __name__ == '__main__':
main()