Python string encryption

I need to encrypt a small string in Python. Can I use a private key to encrypt a string? Is there a good way to do this and achieve a reasonable level of encryption using only Python libraries? Could you show me how to do this?

My knowledge of cryptography is pretty simple.

+3
source share
4 answers

I solved this using the lightweight XTEA library that I found in ASPN. It does not require any additional Python libraries and is quite simple to implement, while providing an acceptable level of encryption.

+2
source

py-bcrypt. , . -:

py-bcrypt - Python OpenBSD Blowfish, " "

+2

KeyCzar . :

Keyczar - , . Keyczar

crypter = Crypter.Read("/path/to/your/keys")
ciphertext = crypter.Encrypt("Secret message")
+2

I recently created a code snippet that does pretty much what you say. It takes a code word, such as "abc'gets values ​​(1, 2, 3), and then adds them to each letter in the word for encryption. Therefore, if" abc "was a code word and" bcd "is the text to be encrypted. (1 + 2 = 3 2 + 3 = 5 and 3 + 4 = 7), so the output will be "ceg"

codeword = input('Enter codeword : ')
codeword = codeword.replace(" ", "")  

encrypt = input('Enter text to encrypt : ')
encrypt = encrypt.replace(" ", "")

j = 0
for i in codeword:
    print(chr(ord(encrypt[j])+ ord(codeword[j])-96))
    j+=1
0
source

Source: https://habr.com/ru/post/1766905/


All Articles