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
Man in America
5 hours agoSICK: Xi & Putin Caught Plotting Organ Transplants for “Eternal Life”
800 watching -
LIVE
Drew Hernandez
7 hours agoMASS CONFUSION AROUND CHARLIE'S MURDER
1,327 watching -
1:01:40
HotZone
6 days ago $2.26 earned"Prepare for WAR" - Confronting the URGENT Threat to America
18K8 -
20:23
Scammer Payback
8 hours agoTerrifying Scammers with File Deletions
8.4K1 -
16:22
The Gun Collective
4 hours agoWOW! 17 New Guns JUST GOT RELEASED!
6.68K8 -
1:13:57
Glenn Greenwald
5 hours agoYoung Men and Online Radicalization: Dissecting Internet Subcultures with Lee Fang, Katherine Dee, and Evan Barker | SYSTEM UPDATE #516
150K45 -
1:14:57
Sarah Westall
2 hours agoCEO of Crowds on Demand: The Fake World of Social Media, Protests & Movements w/ Adam Swart
27.4K2 -
Geeks + Gamers
5 hours agoTuesday Night's Main Event
54.8K2 -
40:36
RiftTV
4 hours agoHow We Got 400 Leftists FIRED for MOCKING Charlie Kirk | The Rift | Guest: Olivia Krolczyk
58.5K29 -
DVR
Badlands Media
18 hours agoBadlands Story Hour Ep 134: Godzilla Minus One
16.8K1