android - Base64 special characters new File -
I'm working on Android, developing an app in which I'm uploading files to the Dropbox as I do this file I do not want to see the title, I am encrypting them and removing the result as a byteyer. The problem is that when you use sentences:
string filename encrypted = base 64. encodeToString (encrypted, base 64.default); File file = new file (mDirectoryPath + "/" + file name encrypted);
In addition to the string "fileNameEncrypted" slash back and forth and possibly other characters that are not allowed for the file name, along with the forward slash subfolders are confused with it.
How can I solve this problem?
PS: My goal is that the file name can not be read in the Dropbox app.
[edit the entire message according to comments]
Because the base64 encode is special Using char (/) and lower / upper case four, it does not correspond to file name for some OS like windows. Where "aaa.txt" file is equal to "AAA.txt".
Base 64 also uses safe mode low and upper case charset.
ASCII provides a more compliant charset 0- 9F for hex format (base 16) store byte array
Four 'A' = 0x41 in base 16 It can be written as "41"
A more complete example
"test.txt" can be translated as: 746573742E747874
If you really want to hide the name, then you can add encoding with a hash function. Because hash is a kind of function, you will definitely hide the file name, but you will not be able to recover the actual name from it.
If you need two types of functions then you can use a simple crypto method with AES
with the internal key to make changes to base 16 or base 32 Use the library library, which is a more compatible charset than the base 64 for windows.
byte [] encrypted = "test.txt" .getBytes (); Base encoding encoder = base encoding.base 16 (). Lower Seas (); String newFilename = encoder Encoded (encrypted);
If you want to change the encoder to base32 juste.
Comments
Post a Comment