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:07:44
Inverted World Live
5 hours agoPentagon Says it Solved UFO Cases, Tyler Robinson "Roommate" Missing | Ep. 113
27K14 -
2:30:00
Badlands Media
12 hours agoDevolution Power Hour Ep. 392: Psyops, Paper Tigers, and the Path to Sovereignty
81.4K11 -
3:02:08
TimcastIRL
6 hours agoLeftist Terror Attack On ICE In Dallas, Jimmy Kimmel Doubles Down Insulting MAGA | Timcast IRL
337K137 -
1:17:35
Man in America
11 hours agoIs Starlink RIPPING Us Apart from the Inside Out? w/ Cory Hillis
41K14 -
55:40
TheSaltyCracker
5 hours agoIdiots Chug Tylenol PT2 ReeEEStream 9-24-25
94.3K223 -
5:55:01
Akademiks
6 hours agoYoung Thug Dissing YFN Lucci. Ready to Go back to Jail. Offset vs Cardi b
57.9K2 -
7:07
Colion Noir
14 hours agoCalifornia Just Banned All Glocks
47.6K40 -
Adam Does Movies
7 hours ago $1.17 earnedTalking Movies + Ask Me Anything - LIVE
39K1 -
1:23:56
Jamie Kennedy
5 hours agoChoosing Good in a World Gone Dark | Ep 223 HTBITY with Jamie Kennedy
33.9K6 -
6:54:11
SpartakusLIVE
9 hours ago#1 Challenge CHAMPION of WZ || Ridin' The GRAVY Train w/ GloryJean
73.4K1