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
Sean Unpaved
1 hour agoMNF Mayhem: Doubleheader Drama, Cheetah's Crushing Fall, & MLB's October Ignition
391 watching -
LIVE
Winston Marshall
46 minutes agoExposing The EU’s Plot To Destroy Free Speech in America | Mike Benz
384 watching -
19:05
Sponsored By Jesus Podcast
2 days agoI Lost the World But Gained My SOUL | Freedom in Christian Suffering
1.14K3 -
14:47
Dr. Nick Zyrowski
15 days agoFasting Is THE Cure - NO FOOD FOR 3 DAYS Completely Heals You!
1.35K7 -
UPCOMING
Badlands Media
10 hours agoGeopolitics with Ghost Ep. 42
5.87K -
2:01:33
Right Side Broadcasting Network
2 hours agoLIVE REPLAY: President Trump Makes an Announcement - 9/30/25
86K24 -
1:56:03
MattMorseTV
3 hours ago $8.19 earned🔴Trump's Oval Office DECLARATION.🔴
43.3K27 -
LIVE
Simply Bitcoin
2 hours ago $0.52 earnedIs $1.6B about to HIT Bitcoin TODAY?! (FTX SAGA ALMOST OVER!) | EP 1343
180 watching -
LIVE
SternAmerican
1 day agoPrecinct Strategy Briefing – Tuesday, September 30 at 1:00 PM EST - Steve Stern & Dan Schultz
89 watching -
LIVE
Rebel News
1 hour agoTruth & Reconciliation Day, Poilievre on anti-Christian hate, No new immigration | Rebel Roundup
353 watching