Premium Only Content

Criptografia de arquivos em Python
Python sem frescura.
Ajude o canal pelo Pix: e1dc2017-053a-4d4f-a018-b35e36527323
Programa que criptografa um arquivo de texto e pode ser recuperado de volta.
Código:
# -*- coding:latin-1 -*-
import time
import getpass, sys
import pyAesCrypt
from os import stat, remove
# encryption/decryption buffer size - 64K
bufferSize = 64 * 1024
escolha = input('digite: \n1- Encript \n2- Decript\nR: ')
password = getpass.getpass('\nDigite a Senha:')
if escolha == '1':
# encrypt
with open("pas.txt", "rb") as fIn:
with open("pas.txt.aes", "wb") as fOut:
pyAesCrypt.encryptStream(fIn, fOut, password, bufferSize)
x = input ('do you want to delete the txt file? y ')
if x != 'y':
print ('\nok')
time.sleep(1)
sys.exit()
remove("pas.txt")
print ('Arquivo removido')
time.sleep(2)
sys.exit()
if escolha == '2':
# get encrypted file size
encFileSize = stat("pas.txt.aes").st_size
# decrypt
with open("pas.txt.aes", "rb") as fIn:
try:
with open("pas.txt", "wb") as fOut:
# decrypt file stream
pyAesCrypt.decryptStream(fIn, fOut, password, bufferSize, encFileSize)
except ValueError:
print ('senha incorreta')
# remove output file on error
remove("pas.txt")
time.sleep(3)
sys.exit()
print ('\n\nEscolha errada')
time.sleep(2)
-
LIVE
Akademiks
3 hours agoWHERE IS WHAM????? Thug we Forgive u dawg.. Ralo vs Boosie. Charlie Kirk fallout. Cardi B album?
2,766 watching -
2:05:53
Inverted World Live
4 hours agoDeath Cult Terror Cells, NASA Bans Chinese Nationals | Ep. 108
54.2K6 -
2:43:57
TimcastIRL
6 hours agoVP Says No Unity With Democrats Celebrating Charlie Kirk Assassination, Left Confirmed | Timcast IRL
262K159 -
13:45
The Charlie Kirk Show
5 hours agoTPUSA AT ASU CANDLELIGHT VIGIL
215K40 -
55:10
Katie Miller Pod
5 hours ago $9.09 earnedEpisode 6 - Attorney General Pam Bondi | The Katie Miller Podcast
78.8K21 -
1:46:41
Man in America
10 hours agoLIVE: Assassin Story DOESN'T ADD UP! What Are They HIDING From Us?? | LET'S TALK
61.3K57 -
2:24:17
Barry Cunningham
6 hours agoFOR PRESIDENT TRUMP WILL TAKE NO PRISONERS AND THE LIBS SHOULD EXPECT NO MERCY!
99K61 -
1:08:41
Savanah Hernandez
6 hours agoCharlie Kirk Was Our Bridge And The Left Burned It
51.8K44 -
1:59:01
Flyover Conservatives
9 hours agoFinancial Web Behind Charlie Kirk's Murder with Mel K | Silver On It's Way to $50 | FOC Show
63.4K3 -
2:36:19
We Like Shooting
17 hours ago $1.12 earnedWe Like Shooting 628 (Gun Podcast)
41.9K