Ok, so I have been messing around with encryption/decryption in java and the encryption I have created uses non-printable/special characters. I then have made an entry in the Registry so that I have the options to Encrypt or Decrypt files in the Windows Context Menu when you right click a file. It encrypts both the file contents, and the file name. Windows has no problem showing these file names but when I try to decrypt the file I get errors and FileNotFoundException
s because the command prompt puts things like ?s in place of the non-printable characters. So how do I pass these file names/characters to my jar file so it can decrypt the file?
This is the batch file that the windows context menu Decrypt button calls to decrypt the file:
java -jar "E:\IdeaProjects\Encryption\out\artifacts\Encryption_jar2\DecryptContext.jar" "%1"
Code converting to Base64
private String encodeBase64(String s) {
return new String(Base64.getEncoder().encode(s.getBytes()));
}
Used then to get:
String newFileName = encodeBase64(encryptedString);
file.renameTo(new File(newFileName + ".txt"));