Skip to content

Simplified interface for encryption of data and files.

Notifications You must be signed in to change notification settings

Marcos-C7/cryptool

Repository files navigation

cryptool

Simplified interface for encrypting and decrypting: raw bytes, text, files and directories.

Read full documentation here


Import the Cryptool class with:

from cryptool import Cryptool

We can create a Cryptool object with:

ct = Cryptool()

We can obtain the hash of a message given by either a raw bytes string or a text string:

h = ct.getHash(b"message")
h = ct.getHash("message")

We can sign a message via an HMAC authenication code:

signed_msg = ct.signMsg(b"message")

We can validate a message signed by the previous method:

validation = ct.validateSgnatureMsg(signed_msg)

We can encrypt and sign a message using a password. We can include a source tag that will be returned when we decrypt the message in the future. The possible tags are "bytes", "str", "file" or "dir":

enc_card = ct.encryptMsg("message", "my password", source="str")
if enc_card["status"] == "OK":
	#... do something with enc_card["signed_data"] ...

We can decrypt a message encrypted by the previous method:

dec_card = ct.decryptMsg(enc_card, "my password")
if dec_card["status"] == "OK":
	#... do something with dec_card["msg"] ...

We can directly encrypt a file, and append a source tag to the encryption to cover the the case when a file is an intermediate step when encrypting a different source of data:

res = ct.encryptFile("my password", "input/file.ext", "output/name", source="file")

We can directly encrypt a directory into a single encrypted file:

res = ct.encryptDir("my password", "input/directory", "output/name")

We can directly decrypt a file encrypted by either of the previous functions. If the encryption corresponds to a directory then its content will be placed in the directory given by the output path parameter:

res = ct.decryptFile("my password", "input/path", "output/path")

About

Simplified interface for encryption of data and files.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages