1

プログラムを公開 (フリーウェア) しようとしていますが、ファイルを暗号化するためのコードを知りたいだけです。(Python 言語 2.7.3)

4

2 に答える 2

3

PyCryptoをチェックしてください

ネイティブの python 実装を検索することもできますが、効率が低下します。

于 2012-10-06T05:37:24.627 に答える
3

ここで必要なもの

def encoder(path,pwd,topath):
    """
    @path: file path you wish to encrypt including filename
    @pwd: seek value 'you should remember that if you want to decrypt it'
    @topath: file path for encrypted file included filename
    """
    k = long(pwd) # key   # password in int
    f1 = open( path, "rb") # file path you wish to encrypt
    bytearr = map (ord, f1.read() ) 
    f1.close()
    f2 = open( topath, "wb" ) # path for encrypt file to write
    random.seed(k)
    for i in range(len(bytearr)):
        byt = (bytearr[i] + random.randint(0, 255)) % 256
        f2.write(chr(byt))
    f2.close()        

Googleで検索しようとしたことがありますか、それともstackoverflowでさえありますか。

于 2012-10-06T04:41:54.533 に答える