cython加密代码python_python通过cython加密代码

python通过cython加密代码,文件夹,文件,代码,路径,密钥

python通过cython加密代码

易采站长站,站长之家为您整理了python通过cython加密代码的相关内容。

#coding=utf-8

import getopt

import os, sys

import zipfile

from Crypto.Cipher import AES

import random, struct

#加密python3的代码

def transfer3(dir_pref):

os.system('cython -2 %s.py;'

'gcc -c -fPIC -I/usr/include/python3.5/ %s.c -o %s.o'

% (dir_pref, dir_pref, dir_pref))

os.system('gcc -shared %s.o -o %s.so' % (dir_pref, dir_pref))

if clear:

os.system('rm -f %s.c %s.o %s.py' % (dir_pref, dir_pref, dir_pref))

else:

os.system('rm -f %s.c %s.o' % (dir_pref, dir_pref))

#加密python2的代码

def transfer2(dir_pref):

os.system('cython -2 %s.py;'

'gcc -c -fPIC -I/usr/include/python2.7/ %s.c -o %s.o'

% (dir_pref, dir_pref, dir_pref))

os.system('gcc -shared %s.o -o %s.so' % (dir_pref, dir_pref))

if clear:

os.system('rm -f %s.c %s.o %s.py' % (dir_pref, dir_pref, dir_pref))

else:

os.system('rm -f %s.c %s.o' % (dir_pref, dir_pref))

#加密AI模型

def encrypt_file(in_filename, out_filename=None, chunksize=64*1024):

"""

使用AES(CBC模式)加密文件给定的密钥。

:param key: 加密密钥-必须是16、24或32字节长。长按键更安全。

:param in_filename: 输入的文件的名称

:param out_filename: 如果为None,将使用“.enc”。

:param chunksize: 设置函数用于读取和加密文件。大块一些文件和机器的大小可能更快。块大小必须可被16整除。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值