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
Kimberly Guilfoyle
2 hours agoIt's a Bad Day To Be a Bad Guy, More Wins for Kash's FBI | Ep218
808 watching -
22:04
James Klüg
1 hour agoJames Klug and Billboard Chris Take On Antifa
-
16:58
T-SPLY
2 hours agoDems’ Bad News: El Salvador Rejects Abrego, Democrats Fume!
625 -
2:10:52
The Quartering
4 hours agoKarmelo Anthony SPENDING SPREE, Kamala Harris Hammered Drunk, Catturd Blasts Rumble & Superman Woke
78.2K25 -
LIVE
StoneMountain64
3 hours agoArc Raiders is my most ANTICIPATED game of the year now
327 watching -
5:07:42
Viss
5 hours ago🔴LIVE - PUBG EXTRACTION SHOOTER CONFIRMED BY END OF YEAR! - PUBG
9983 -
1:49:27
The Sage Steele Show
4 hours ago $5.76 earnedMy Parents! Mona and Gary | The Sage Steele Show
17.8K8 -
57:31
Russell Brand
4 hours agoHalf of Congress Are Millionaires… Now They Want to Ban Insider Trading? – SF576
115K59 -
1:03:08
Sean Unpaved
3 hours agoNBA Elimination Battles & Pittsburgh's Safety Wake-Up
35.6K3 -
1:03:00
Jeff Ahern
2 hours agoThursday Thrash With Jeff Ahern
2.63K1