How can I encrypt a string with Triple DES and output format of base64

679 views Asked by At

I'm trying to get some help regarding encoding with Triple DES in python. I want to have 2 functions: encode/decode and I want it to operate as it does on the site: https://www.devglan.com/online-tools/triple-des-encrypt-decrypt, with the base64 output format. because when I decode that base64 msg I get some random chars and that's what I want. I've tried doing that with pycryptodome but it gives me a byte output.

what I've tried:

from Crypto.Cipher import DES3
from Crypto.Random import get_random_bytes

# Avoid Option 3
while True:
    try:
        key = DES3.adjust_key_parity(get_random_bytes(24))
        break
    except ValueError:
        pass

cipher = DES3.new(key, DES3.MODE_ECB)
plaintext = b'We are no longer the knights who say ni!'
msg = cipher.iv + cipher.encrypt(plaintext)

How would I be able to do that? any help would be appreciated! Or maybe do you know what most programs use to encrypt their files? for example word.

0

There are 0 answers