I'm using Django I want to convert text to hex and than base64
I tried to do like this:
# create text or number and convert them to integer #
txt = "ABC"
txt_to_int = int(txt,16)
print(txt_to_int)
>> 2748
# convert them to hex
txt_to_hex = hex(txt_to_int)
print(txt_to_hex)
>> 0xabc
# convert to base64
hex_encode = txt_to_hex.encode('utf-8')
hex_to_base64 = base64.b64encode(hex_encode)
base64_decode = hex_to_base64.decode("utf-8")
print(base64_decode)
>> MHhhYmM=
I am using Online Text To Hex Converter Tool I want result as:
https://string-functions.com/string-hex.aspx
after Converter : text to hex:
(ABC) to hex (414243)
https://base64.guru/converter/encode/hex
after Converter : Hex to Base64
(414243) to base64 (QUJD)
I want to do them by django-python
any help I will appreciate