mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-01 23:47:40 +00:00
feat: 密码计划邮件提醒
This commit is contained in:
19
apps/common/utils/file.py
Normal file
19
apps/common/utils/file.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import os
|
||||
import csv
|
||||
import pyzipper
|
||||
|
||||
|
||||
def create_csv_file(filename, headers, rows, ):
|
||||
with open(filename, 'w', encoding='utf-8-sig')as f:
|
||||
w = csv.writer(f)
|
||||
w.writerow(headers)
|
||||
w.writerows(rows)
|
||||
|
||||
|
||||
def encrypt_and_compress_zip_file(filename, secret_password, encrypted_filename):
|
||||
with pyzipper.AESZipFile(
|
||||
filename, 'w', compression=pyzipper.ZIP_LZMA, encryption=pyzipper.WZ_AES
|
||||
) as zf:
|
||||
zf.setpassword(secret_password)
|
||||
with open(encrypted_filename, 'rb') as f:
|
||||
zf.writestr(os.path.basename(encrypted_filename), f.read())
|
Reference in New Issue
Block a user