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)
-
2:04
Sean Unpaved
11 hours ago $0.73 earnedUnpaved w/Sean Salisbury
46.4K4 -
LIVE
The Connect: With Johnny Mitchell
8 hours agoInside The War For Tijuana: How Mexican Cartels Turned Tijuana Into World's Most VIOLENT City
415 watching -
12:34
TimcastIRL
8 hours agoWaPo Staffers QUIT Over Bezos’ Change To Opinion Section, Liberal Media MELTING DOWN
59.7K51 -
24:55
MYLUNCHBREAK CHANNEL PAGE
1 day agoThe Sumerian King's List
83.6K29 -
LIVE
Man in America
11 hours agoIs Trump Using Gold to Dismantle the City of London Banking Cartel? w/ Eric Yeung
1,377 watching -
33:50
The Why Files
8 days agoCryptids Vol. 3: The Antarctic Cover-up | Predators Beneath the Ice
102K132 -
27:11
Stephen Gardner
11 hours ago🔥Trump Zelensky Meeting ends in IMPEACHMENT | MUSK shares major dirt on Joe Rogan Podcast
100K247 -
2:40:23
Jewels Jones Live ®
3 days agoTRUMPARENCY | A Political Rendezvous - Ep. 112
95K26 -
1:13:14
Michael Franzese
11 hours agoEmergency Livestream: Zelenskyy vs Trump, DOGE, Epstein Files, Elon Musk
118K84 -
1:32:06
The Quartering
11 hours agoZelensky Comes CRAWLING BACK, Fed Ex Jet BURSTS Into Flames, Elon's Psycho Ex & More
145K162