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)
-
12:37
itsSeanDaniel
1 day agoFake Republican REFUSES to Stand Up for Charlie Kirk
1.3K8 -
1:01:55
MTNTOUGH Podcast w/ Dustin Diefenderfer
20 hours agoJason Khalipa: American Men: Get Off the Couch and Rise Up Now | MTNPOD #133
14.6K23 -
5:17
Blackstone Griddles
11 hours agoEasy Weeknight Meals: Creamy Parmesan Beef Pasta
3.02K2 -
7:08
Rena Malik, M.D.
21 hours ago $0.49 earnedFour totally surprising causes of Back Pain
4.28K1 -
6:27
DropItLikeItsScott
13 hours ago $0.27 earnedIs This the Coolest Gun Accessory Ever? The Gun Guardian
3.2K -
19:05
Michael Feyrer Jr
22 hours agoCan you even fit this much FAIL in one video? $10K Challenge Week 1
3.9K -
19:53
Professor Nez
15 hours agoYou WON’T BELIEVE What I Found on Charlie Kirk’s Shooter!
5.54K15 -
1:35:53
The China Show
17 hours ago $0.97 earnedBrutal Mayhem in China as Dark Coverups are Exposed - #280
12.6K5 -
12:30:34
Times Now World
23 hours agoLIVE | Russia-Belarus Zapad-2025 LIVE | Missiles Target NATO in Arctic & Baltic
25.1K1 -
32:14
daniellesmithab
17 hours agoNew Feature for Driver’s Licence and ID Cards
28.8K6