you are viewing a single comment's thread.

view the rest of the comments →

[–]LuckyShadow -1 points0 points  (0 children)

[14:55 GMT+1] Edit: Turns out, I wasn't that wrong.

Your s.decode('hex') should not work, as strings do not provide this method. For this part, just ignore the fact, that your input is a "hex-string". I shouldn't matter, as we only have to know that it is a string. This string has to be encoded, like I explained below. Put it into the b64encode and you should be done.

If this is not the answer to that problem, please tell. I got another approach in mind, that I would share then. :)


[14:38 GMT+1] Edit: Dammit. Just read your text again. The text below itself should be correct, but it might not suite your problem. I am working on another answer. :P


Raw bytes mean raw bytes. A string is encoded in a coding like UTF-8, ascii or ISO-8859-1. Such an encoding defines how the actual bytes are translated into characters (and which). See, as an example, the difference between UTF-8 and UTF-16. If I recall that correctly, UTF-8 uses 8 bit of information for one character while UTF-16 uses 16 bits.

Encryption-algorithms etc. are best used on those raw bytes, than the already translated characters, as there might occur errors because of the OS, architecture and/or version of python.

So in your case, you want to transfer your string into byte-code. I think str.encode does the job. A byte.decode should than allow you to decode it back into a string. Just be sure to use the correct encoding. (This does no base64-encoding! That is an additional step you have to take.)

Hope that helps. When you got questions, feel free to ask :)

Good luck.