Is Base64 encoding safe to use for filenames on Windows and Linux systems? From my research I have found that replacing all
/ characters of the result with
_ should resolve any issues.
Can anyone provide more details on this?
Currently in Java I am using the following peice of code:
MessageDigest md5Digest = MessageDigest.getInstance("MD5");md5Digest.reset();md5Digest.update(plainText.getBytes());byte digest = md5Digest.digest();BASE64Encoder encoder = new BASE64Encoder();hash = encoder.encode(digest);hash.replace('/','_');
There are algorithms for encoder which are impossible to hack and these encoder are used in applications like HTTPS for sending secure message over network. Base64 is very simple and can be easily decoded, I think encoding with base64 is as simple as sending raw data.Then why base64 encoding is used? For example Elasticsearch automatically generates id which is encoded with base64
I am trying to encode a file which is in a certain folder and create a base64 string. I can load the file and read() it, but creating the base64 string prints nothing.
for file in os.listdir(os.path.join(app.config['UPLOAD_FOLDER'])): print file print type(file) if file.startswith(str(current_user.id)): with open(file, 'rb') as thefile: data = thefile.read().encode("base64") print "base: ", data print "the ", type(thefile)
Here are the prints:
1-bild-1.jpg<type 'str'>base: the <type 'file'>
I noticed that
thefile.read() is empty aswell. print shows nothing.
I am trying to encode a text string to base64.
i tried doing this :
name = "your name"print('encoding %s in base64 yields = %s\n'%(name,name.encode('base64','strict')))
But this gives me the following error:
LookupError: 'base64' is not a text encoding; use codecs.encode() to handle arbitrary codecs
How do I go about doing this ? ( using Python 3.4)
I have a string say
FhY= which has been encoded to hex. So when run
>>> b6 = 'FhY='>>> b6.decode('base64')'\x16\x16'
This is a hex string that once converted should be
22 22. This result has been proven on the site https://conv.darkbyte.ru/. However, I cannot seem to do a proper conversion from base64 to decimal representation. Some of the challenges I am facing are
base64 > base16(Convert a base64 encoded string to binary),
base64 > binary > decimal(Convert hex string to int in Python) both of which have failed.