linux下如何创建python文件夹_如何使用python在linux中创建受密码保护的文件夹/文件...

def discover():

#file_path = ''

#print file_path

for root, dirs, files in os.walk(r'/root/Desktop/rakesh/rakeshp/dlp'):

for file_name in files:

file_path = os.path.join(root, file_name)

#print file_path

file_list = []

if file_path.endswith('.py'):

file_list.append(file_path)

dict = {}

status=""

for p in file_list:

if not os.access(p, os.F_OK):

dict[p]=status=status+"NOEXISTS"

if(os.access(p,os.R_OK)):

dict[p]=status=status+"READ,"

if(os.access(p, os.W_OK)):

dict[p]=status=status+"WRITE,"

if (os.access(p, os.X_OK)):

dict[p]=status=status+"EXECUTE"

elif os.access(p, os.F_OK) and not (os.access(p,os.R_OK)) and not (os.access(p, os.W_OK)) and not (os.access(p, os.X_OK)):

dict[p]=status=status="NOACCESS"

status="" # Set blank before we enter the loop again

os.chmod(file_path,0444)

for size in file_list:

size = os.path.getsize(file_path)

#print size

#print (dict)

in_filename = file_path

#print in_filename

if not out_filename:

out_filename = in_filename + '.enc'

iv = 16 * '\x00'

#iv = bytes([random.randint(0, 0xFF) for i in range(16)])

#print iv

encryptor = AES.new(key, AES.MODE_CBC, iv)

with open(in_filename, 'rb') as infile:

with open(out_filename, 'wb') as outfile:

outfile.write(struct.pack('

outfile.write(iv)

while True:

chunk = infile.read(chunksize)

if len(chunk) == 0:

#print (chunk)

break

elif len(chunk) % 16 != 0:

chunk += ' ' * (16 - len(chunk) % 16)

#print (chunk)

outfile.write(encryptor.encrypt(chunk))

if __name__ == "__main__":

discover()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值