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
#!/bin/bashlink='unsubscribe'testVar="$link/""me@domain.com"echo "www.somedomain.com/$testVar/email/"
Output:
www.somedomain.com/unsubscribe/me@domain/email/
I am trying to encode email with base64 like this:
#!/bin/bashlink='unsubscribe'testVar="$link/""me@domain.com"|base64echo "www.somedomain.com/$testVar/email/"
Output
www.somedomain.com/unsubscribe//email/
Notice the email did not get encoded, returned empty value
what I am missing here?
I understand that .terminal
files use base64 encoding to go from (what looks like) sRGB to a data value that the default Mac Terminal app can interpret.
As suggested here, I can decode base64 text into text that is somewhat more understandable using something like
echo IzEyMzQ1Ngo= | base64 --decode# returns #123456
However, when converting existing .terminal
data values using the above method I am left with text that looks like
UNSRGB\NSColorSpaceV$classO*0.08235294118 0.08235294118 0.08235294118��Z$classnameX$classesWNSColor�XNSObject_NSKeyedArchiver�Troot#-27;AHN[b
How can I go from a hex color value (ex: #123456) to the base64 value that is needed for a .terminal
file for a color preference (the ANSI color preferences) using the command line?
I need to use SendGrid to send emails from my application. I've made the transactional templates in sendgrid and now need to attach excel to the emails that go out.
According to their Web API V3 documentation, the attachment can be added by encoding the file in Base64. I've tried searching for solutions to encode the file in Base64, but can't find a solution to it. From what I understand of the base64 package, it can only encode bytes-like objects.
So, do I need to read the excel file into a byte-like object before I can encode it? Is there a package that will do this for me magically?
My application currently generates the excel file by using the pandas to_excel() method.
Thanks in advance :)
[Update 1]I've checked this question if mine could be a duplicate, however, that question returns the file as a String, but to do the Base64 encoding, I need a byte-like object to encode my excel file.
I did try the solution provided in that question but it did not work because the final return was a string.
I need an efficient (read native) way to convert an ArrayBuffer to a base64 string which needs to be used on a multipart post.
private static String encodeFileToBase64Binary(String fileName) throws IOException { File file = new File(fileName); byte[] bytes = loadFile(file); byte[] encoded = Base64.encodeBase64(bytes); String encodedString = new String(encoded,StandardCharsets.US_ASCII); return encodedString;}private static byte[] loadFile(File file) throws IOException { InputStream is = new FileInputStream(file); long length = file.length(); if (length > Integer.MAX_VALUE) { // File is too large } byte[] bytes = new byte[(int)length]; int offset = 0; int numRead = 0; while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) { offset += numRead; } if (offset < bytes.length) { throw new IOException("Could not completely read file "+file.getName()); } is.close(); return bytes;}
// to get encode string
String encoded=encodeFileToBase64Binary("file.fmr");
// encoded string is :
Rk1SACAyMAAAAAFiAAABQAHgAMUAxQEAAABGNkDZADP/SEC8AD6CSECqAEcGSED+AFJtO0CgAGCKZEC6AGuFZEDgAHz1ZECzAI6HZEENAJluNEBWAJ4ZZEB1AKkTZEECALbuZEA/ALqfSECCALySSECxAMP/ZECIAMURVUAXAN2jGkCnAOD8ZEAoAOWlZEBnAOyhLkCyAP/tZECHAQMSGkD8AQTdZECfASKFGkCHASUaGkA1ASy6ZEDAAS3JZEDPAS7NZEAnATG4ZEDxATzOZEBOAUPLZEBzAVbuGkCAAWF8NEDTAWsxLkDnAXa0LkC/AX2nLkC0AYojIEBMAYvkSEDJAa0fT0CsAbwVIIDqANTsZIDIAPfnZICbAQKHO4D5AR/XZIBlASS7IIEoASbYO4CsAUetLoDvAVXSZIDaAVvDO4EHAWrLZICsAX2fNIDnAYEwNIDQAZKnT4BfAZxtZAAA
//encoded string from file using some other source.
Rk1SACAyMAAAAAFiAAABQAHgAMUAxQEAAABGNkCLACELSEDAADYDZEEYAGFxO0DGAGJ9SEC1AGkCSEA6AHWYVUDJAHp5ZEBEAHwVZECVAJgIZEEaALHrZEB4ALuOZEELAMFqZEEzAM/sNEDRANvwZEBkAN0VZECcAOIAZEEwAOjnLkEvAPXlO0CnAP71ZEB7AQYRNEBdAQ0eZED8ARDhZEDXASXcZECZAS3uGkBoAT4eO0AUAUMxSEA7AUYqZEDxAUnSZECmAVNDO0EIAXDHSEDYAXW7ZEEUAXXKSEEGAYY8IEEhAYrDNEDfAZ81ZEDQAcGqLoEBAC/7O4EGAE7zVYB+AP2QSICEARuLZIBnATUfO4D/ATXaZIDEATjSZIDRATrVZICnATvSNIBTATwnZIARAV1LGoB1AV2oO4CrAV68SIDnAWHGZIB+AWauNICVAX0ySICNAYytO4CJAZorSAAA
When i am trying to match both the encoded string , i am getting a missmatch.please suggest method for encode file to base64 to match encoded string found from other source.i have tried with StandardCharsets.UTF_8
and StandardCharsets.US_ASCII
.
Please note that by viewing our site you agree to our use of cookies (see Pribadi for details). You will only see this message once.