Skip to content

Commit

Permalink
Fix bug - Change encryption key generation
Browse files Browse the repository at this point in the history
Encryption key generation should use secrets package rather than
generating key from a variable defined.
This fixes bug rexdivakar#8
  • Loading branch information
SanchitJain123 committed Sep 28, 2020
1 parent 1092bc4 commit d3b57e1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions File_Encryptor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import hashlib
import pyAesCrypt
import random
import os,time
import shutil
import secrets

import email, smtplib, ssl
from email import encoders
Expand All @@ -25,8 +25,7 @@
fname=input(str('Enter file path (without quotes): '))
#fname='test.zip'
try:
sub_key="abcdefg!~hijklm#$&*nopqrstuvw-+@xyz02345+/67890A-)(%BCDEFGHIJKLMNOPQRSTUVWXYZ"
enc_key = "".join(random.sample(sub_key,30))
enc_key = secrets.token_hex(30)
pyAesCrypt.encryptFile(fname,fname+'.aes',enc_key,buffer)
os.remove(fname)
print('''----------Encryption Sucessfull----------\n \nUser Warning: Make sure to notedown the encryption key,
Expand Down Expand Up @@ -59,8 +58,7 @@
#fol='Dataset'
if not os.path.exists('encrypted_folder'):
os.mkdir('encrypted_folder')
sub_key="abcdefg!~hijklm#$&*nopqrstuvw-+@xyz02345+/67890A-)(%BCDEFGHIJKLMNOPQRSTUVWXYZ"
enc_key = "".join(random.sample(sub_key,30))
enc_key = secrets.token_hex(30)
for i in os.listdir(fol):
if i[-4:]!='.aes':
try:
Expand Down

0 comments on commit d3b57e1

Please sign in to comment.