Code Monkey home page Code Monkey logo

simple_encryption's Introduction

说明

借助cryptography库对文件进行加密解密,可以直接作为工具对文件进行加解密,也可以在代码中作为上下文管理,对需要解密的文件进行临时解密使用

依赖

  • cryptography

安装

pip install .

使用说明

默认密码是imsohandsome

作为单独的工具使用

比如要加密文件大国崛起.mp4

python -m simecy -f ./大国崛起.mp4 -m e -pd imsohandsome

同目录下应该会生成大国崛起.mp4bytes 同理解密

python -m simecy -f ./大国崛起.mp4bytes -m d -pd imsohandsome

同目录下应该会生成大国崛起.mp4

在代码中使用

假如我们已有一个神秘的secret.txt文件已经使用上述命令加密变成了secret.txtbytes,现在解密如下:

from simecy import decrypt
import yaml
with decrypt("./secret.txtbytes","imsohandsome") as d:
    # do your work ,for example:
        with open(d,"r") as fr:
            line=fr.readline()
        ...

TODO

  • 可以手动设定解密文件的生命周期
  • 只有上下文管理的方式有点脏

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.