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)
-
34:27
The Connect: With Johnny Mitchell
12 hours ago $5.73 earnedCan He Stop Them? Inside Trumps War On Mexican Drug Cartels & The New Era Of Mexican Organized Crime
13.5K2 -
2:33:15
Tundra Tactical
4 hours ago $4.68 earnedLuis Valdes Of GOA Joins The Worlds Okayest Firearms Live Stream!!!
14.9K -
1:03:41
Man in America
13 hours agoAre Trump & Musk the COUNTER-ELITES? w/ Derrick Broze
43.6K27 -
3:45:08
DLDAfterDark
4 hours ago $5.67 earnedDLD Live! SHTF Handguns! Which Would You Choose?
24.4K1 -
1:50:38
Mally_Mouse
6 hours agoSaturday Shenanigans!! - Let's Play: Mario Party Jamboree
36.2K -
1:13:00
Patriots With Grit
10 hours agoWill Americans Rise Up? | Jeff Calhoun
29.1K10 -
14:55
Exploring With Nug
11 hours ago $9.92 earnedWe Found Semi Truck Containers While Searching for Missing Man!
47.6K7 -
27:57
MYLUNCHBREAK CHANNEL PAGE
18 hours agoOff Limits to the Public - Pt 3
98K62 -
38:07
Michael Franzese
11 hours agoLeaving Organized Crime and Uncovering Mob in Politics: Tudor Dixon and Michael Franzese
85.5K15 -
2:42:54
Jewels Jones Live ®
2 days agoAMERICA IS BACK | A Political Rendezvous - Ep. 111
69K46