コード例 #1
0
ファイル: cmdutils.py プロジェクト: jungkumseok/jkspy
def encrypt(pubkeypath, filepath):
    pubkey = crypto.open_keypair(pubkeypath)
    content = readFile(filepath)

    crypto = crypto.encrypt(pubkey, content)

    writeFile(filepath + ".secret", crypto, True)
コード例 #2
0
ファイル: cmdutils.py プロジェクト: jungkumseok/jkspy
def decrypt(prvkeypath, filepath):
    try:
        prvkey = crypto.open_keypair(prvkeypath)
        content = readFile(filepath, True)

        plain = crypto.decrypt(prvkey, content).decode()

        writeFile(filepath + ".plain", plain)
    except ValueError:
        print("Could not decrypt [" + filepath + "]")
コード例 #3
0
ファイル: crypto.py プロジェクト: jungkumseok/jkspy
def open_keypair(keypath):
	keystr = readFile(keypath, True)
	try:
		keys = RSA.importKey(keystr)
	except ValueError:
		print("Enter password for the private key")
		pw = input(' >> ')
		try:
			keys = RSA.importKey(keystr, pw)
		except ValueError:
			print("...Wrong password")
			raise ValueError("Wrong Password")
	return keys
コード例 #4
0
ファイル: cmdutils.py プロジェクト: jungkumseok/jkspy
def sdecrypt(passphrase, filepath):
    ciphertext = readFile(filepath, bytestring=True)
    plaintext = crypto.sdecrypt(passphrase, ciphertext)
    print(plaintext)
    writeFile(filepath + ".unlocked", plaintext)
コード例 #5
0
ファイル: cmdutils.py プロジェクト: jungkumseok/jkspy
def sencrypt(passphrase, filepath):
    plaintext = readFile(filepath)
    ciphertext = crypto.sencrypt(passphrase, plaintext)
    print(ciphertext)
    writeFile(filepath + ".locked", ciphertext, bytestring=True)