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:38:56
FreshandFit
14 hours agoShe Left Her Man To Find A HVM In Miami w/ 6IX9INE
365K148 -
11:16
Blackstone Griddles
13 hours agoDouble Roasted Green Chile Smash Burger on the Blackstone Griddle
7.13K2 -
14:36
Tactical Advisor
17 hours agoNew Military Thermal Target
12.7K2 -
2:10
OfficialJadenWilliams
16 hours agoHow we treated AI in 2023 vs 2025
3.41K2 -
9:02
The Shannon Joy Show
17 hours agoWhy is Canada PERSECUTING Dr. Makis
5.94K6 -
57:03
NAG Podcast
13 hours agoAlex Stein: BOLDTALK W/Angela Belcamino
7.05K1 -
8:41
Freedom Frontline
16 hours agoMaria Bartiromo Plays The Clip That ENDS Adam Schiff’s Career
5.69K4 -
9:39
Nate The Lawyer
1 day ago $1.89 earnedBlack Family Turns On BLM Narrative Says Cop Was Justified.
12.1K19 -
32:41
Actual Justice Warrior
2 days agoFinance Girl Goes FULL PROPAGANDIST
10.8K6 -
12:21
itsSeanDaniel
1 day agoAOC and Bernie MELTDOWN after CNN Host CALLS THEM OUT
9.98K9