Source |
CodingSec |
Identifiant |
360578 |
Date de publication |
2017-05-01 15:08:38 (vue: 2017-05-01 15:08:38) |
Titre |
How to encrypt a file in python |
Texte |
Given the popularity of Python, at first I was disappointed that there was no complete answer to this question to be found. It took me a fair amount of reading different answers, as well as other resources, to get it right. I thought I might share the result for future reference and perhaps review; I’m by no means a cryptography expert! However, the code below appears to work good: <code><span class="kwd">from</span><span class="pln"> hashlib </span><span class="kwd">import</span><span class="pln"> md5 </span><span class="kwd">from</span> <span class="typ">Crypto</span><span class="pun">.</span><span class="typ">Cipher</span> <span class="kwd">import</span><span class="pln"> AES </span><span class="kwd">from</span> <span class="typ">Crypto</span> <span class="kwd">import</span> <span class="typ">Random</span> <span class="kwd">def</span><span class="pln"> derive_key_and_iv</span><span class="pun">(</span><span
|
Envoyé |
Oui |
Condensat |
</span><span <code><span <span aes amount answer answers appeared appears below class="kwd">def</span><span class="kwd">from</span> class="kwd">from</span><span class="kwd">import</span> class="kwd">import</span><span class="pln"> class="pun"> class="typ">cipher</span> class="typ">crypto</span> class="typ">crypto</span><span class="typ">random</span> code coding complete cryptography derive different disappointed encrypt expert fair file first found future get given good: hashlib how however i’m iv</span><span key md5 means might other perhaps popularity post python question reading reference resources result review; right security share thought took well work |
Tags |
|
Stories |
|
Notes |
|
Move |
|