I have a string containing mathematical symbols which I want to encode and decode in java.
I want to know whether encoding and decoding by 'Base64' will suffice for the same.
Can you please help me to know that 'Base64' supports mathematical symbols? like,
I've heard people talking about "base 64 encoding" here and there. What is it used for?
I encode data of images in base64 using python before sending it to the server which is written in C#. The data that is received is identical to the data that is being sent. However, when I decode the encoded string I get a different result. Here is the code that takes a screenshot and encodes it in base64:
screen_shot_string_io = StringIO.StringIO()ImageGrab.grab().save(screen_shot_string_io, "PNG")screen_shot_string_io.seek(0)return base64.b64encode(screen_shot_string_io.getvalue())
it is sent as is to the server and the server receives the encoded string correcetly with no data corruption.
Here is the c# code that decodes the string:
byte decodedImg = new byte[bytesReceived];FromBase64Transform transfer = new FromBase64Transform();transfer.TransformBlock(encodedImg, 0, bytesReceived, decodedImg, 0);
So does anyone know why when the data is decoded the result is incorrect?
I am trying to prepare url, in which email address will be base64 encoded. However when I encode the email with base64 it returns emptry string, without base64 encode this works fine, what am I missing here?
here is shell script without base64 encode
I am trying to encode email with base64 like this:
Notice the email did not get encoded, returned empty value
what I am missing here?
I have written python code where I need file's md5/sha1 digest for further use.
import hashlibmd5_file = hashlib.md5(my_file_path).digest()
which will generate digest of this sort.
Now this is hexadecimal representation of md5 in 16 bit.Next what I did was converted it into list
md5hexstring = list(md5_file)o/p = ['s', 'i', '\x15', '5', 'u', '\xba', '\xd2', '\xf9', 'N', '^', '\xab', 'q', '\xc8', '7', '\xff', 'h']
now I want to encode this using custom encoding which has logic like this.
pseudo code of logic I want to use:char_val >> 4 thenif char_val < 6 : new_val = char_val + '3' else : new_val = 'x' + char_val - 7encoded_val = encoded_val + new_valagain char_val & 0x0f thenif char_val < 6 : new_val = char_val + '3' else : new_val = 'x' + char_val - 7encoded_val = encoded_val + new_val
ascii value of character 3 is added eg. '3'=>51 + char_val =
Now this is typically easy in C++ to do but in python I tried
chr() but this having limit of 255 and checksum calculation will typically have value more than that. So I am not sure how to do this in python.
2 questions here are:
Is the way I am converting digest to list for each character processing is correct ? (if not then what is correct way)
How do I do the custom encoding according to the pesudocode which I have mentioned above.
I don't want to use
encode() api of python for base64 encoding as I need my custom encoding as mentioned above, so please do not suggest that unless I can add my this logic into this api.
Tried referring this but no luck