Aug-09-2020, 03:03 PM
Hi all,
I'm new to Python and probably I'm not going to be a good programmer. however, I have a use case that I try to complete:
I need a Python script that will ask me to type a password which will be encrypt and will place it into an external file.
I also need the decrypt as I'm going to use this bit for SSH using paramiko
I've search so much across the net, but didn't find how to do it. or else I'm just very bad at python and didn't get it :(
I came across this link which is very useful
https://www.thepythoncode.com/article/en...ric-python
but that's not exactly how I need it to work.
so here I am, trying to ask experts
btw I've tried the code below which is clearly not good
I'm new to Python and probably I'm not going to be a good programmer. however, I have a use case that I try to complete:
I need a Python script that will ask me to type a password which will be encrypt and will place it into an external file.
I also need the decrypt as I'm going to use this bit for SSH using paramiko
I've search so much across the net, but didn't find how to do it. or else I'm just very bad at python and didn't get it :(
I came across this link which is very useful
https://www.thepythoncode.com/article/en...ric-python
but that's not exactly how I need it to work.
so here I am, trying to ask experts
btw I've tried the code below which is clearly not good
#!/usr/bin/env python3 print("Please type your new password.""\n") text_file = open("sessionsdb.txt", "w") value_list = [] for i in range(1): print("New password: ") line = input() value_list.append(line + "\n") text_file.writelines(value_list) text_file.close() print("Your password has been encrypted.""\n") from typing import List file = open("sessionsdb.txt") sessionsdb: List[str] = file.read().splitlines() from cryptography.fernet import Fernet key = b'PCHl_MjGyEyBxLYha3S-cWg_SDDmjT4YYaKYh4Z7Yug=' cipher_suite = Fernet(key) ciphered_text = cipher_suite.encrypt(b'sessionsdb[0]') unciphered_text = (cipher_suite.decrypt(ciphered_text)) print(unciphered_text) print(ciphered_text)