I want to send the .p12 file of APNS certificate to One Signal API, but I need first to convert the .p12 file to base64 string. How do I do that?
The API documentation is below:
https://documentation.onesignal.com/reference#create-an-app
If you're on a Mac you can use the base64 utility that comes with Mac.
base64 -i certificate.p12 -o outputfile
This depends on the programming language you are using.
For example, here's how to do it in Ruby:
base64_encoded_p12 = Base64.encode64(File.read('/path/to/your/file.p12'))
new Buffer(fs.readFileSync(__dirname + "/ios_push_certificate.p12")).toString('base64')
That is the correct script after all.
You can use this on Linux
base64 file.p12
To write the base64 output to any file, you can use this
base64 file.p12 > output.base64
Note: This works for any files not only .p12
Related
so I started using Yara rules,
I have a mysql database with files and their base64 encodes saved in a column.
Is there any way to input in Yara a base64 string without storing it in a file? if so, what is the command? If not, is there a way in Python?
This is what I tried to do:
rule string_exist{
strings:
$a = "just for use in the Virtual Mechanics tutorials. More text. And more" base64
condition:
$a
}
and then in cmd: yara64.exe -r manual_code.yar ..........long base64 string``
but recieved an error: could not open file
Thanks in advance.
We receive a BASE64 encoded representation of a courier label PDF in an xml file, which we store in the IFS of our AS400.
We would like to decode this BASE64 string and save it as a .PDF in the IFS so we can then either email it as an attachment or send it to a printer.
I have looked at the capability of the CPYSPLF command using the *PDF WSCST parameter, but this only seems relevant where we would have a Spooled File representation of the label we want to produce.
Does anyone know if this is possible via native iSeries commands/RPG?
One way is to
IFS_READ_UTF8 to load the XML file
XMLPARSE to make it a XML object
XML_TABLE to extract BASE64 data
BASE64_DECODE to decode B64 data to PDF binary stream
IFS_WRITE_BINARY to write that stream as a .pdf file
You could make it a pure sql prodecure, or a SQLRPGLE program.
You also could extract BASE64 date using RPGLE XML-INTO. The use Scott Klement's BASE64 SRVPGM to decode it, then write it to the IFS
I am trying to use LND to create an invoice and then check it. This is quite easy using the command line, but I'm stuck on the encoding of the r_hash in the HTTP API. Docs can be found here.
If I create an invoice using:
curl -X POST 'https://localhost:8080/v1/invoices' -k -H 'Grpc-metadata-macaroon: my-macaroon'
I get something along the lines of
{
"r_hash":"ud8NgqDTgCUri3sqb8D85YaRsnCtnQzY56iLwGWUXA4=",
"payment_request":"lnbc1ps5xjcxpp5h80smq4q6wqz22ut0v4xls8uukrfrvns4kwsek884z9uqev5ts8qdqqcqzpgxqyz5vqsp5c0sxrfllt0hste83mevptfyvgcf9csg05rg8326vvhl9a0mfm73s9qyyssqgcehn536edaxhjpycu4hedl9klkqtkknnng653fdfqxxwpcdncus7gkmtxy9wpeezw9tupwh4nunpt9f0yg233233xgs0c2qpnlqe4sq7jlqxp",
"add_index":"61",
"payment_addr":"w+Bhp/9b7wXk8d5YFaSMRhJcQQ+g0HirTGX+Xr9p36M="
}
The r_hash here is different from what the cli gives me when I look up the invoice: b9df0d82a0d380252b8b7b2a6fc0fce58691b270ad9d0cd8e7a88bc065945c0e.
My problem is I don't know how to convert between the two. I've tried hex and base64. The docs say the r_hash must be encoded as base64.
Got it. The API was returning the hash base64 encoded, and I was able to get the API to accept it hex encoded. This required decoding and re-encoding:
import codecs, base64
codecs.encode(base64.b64decode(h.encode('utf-8')), 'hex')
I have a file containing a svg image which is base64 encoded (data-uri). The file starts with
data:image/svg+xml;base64,PHN....
How to decode this to a .svg file in linux ?
You can copy/paste the string (data:imageetc included) in the url bar of a modern browser; it will decrypt it for you, then you can simply save the page as an svg.
You could use an online base64 decoder, such as http://www.base64decode.org/
To address the OP question:
How to decode this to a .svg file in linux ?
Since linux has python by default, I suggest to use python script.
Here is a working example:
import base64
#change "YOURFILE" with the name of your original file
with open("YOURFILE", "rb") as f: encoded = f.read()
encoded = encoded.replace("data:image/svg+xml;base64,", "")
decoded = base64.b64decode(encoded)
#change "NEWFILE" with the name that you want to give your new svg
with open("NEWFILE.svg", "wb") as f: f.write(decoded)
If you are new to python, simply copy-paste the code above into a file with .py extension, for example aaabbb.py and then execute it like this:
python aaabbb.py
You can use e.g base64 --decode < "your base64 data here". And you probably need to strip off the data:image/svg+xml;base64, part before passing it in.
or you can use the online tool
http://www.hosting4free.info/Base64Decode/Base64-Decode.jsp
I use SVG online decoder, fast and simple
https://base64.online/decoders/decode-base64-to-svg
I resolved problem:
let base64 = 'data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMM...'
let url = base64.replace("data:image/svg+xml;base64,", "");
var svg = decodeURIComponent(escape(window.atob(url)));
I have a text file, that contains 50,000 lines of "strange" text:
UEsDBBQAAgAIACaOVEA6e5H83pcBAMLBAQArAAAAW1NhbXN1
bmddIC0gVGVzdCB0YXNrIC0gU291bmQgZGVjcnlwdG9yLnBu
Z+z9ZVBcXdcFiia4B/cgTQPBJTgEC9bBEtwCBCe4uwVtNN24
QyAQ3C24OwR3d3e303zv++T57vl5761zbt06VV3V1bLWXjLX
mGOuNcfe4I8K0phopGgvXrzABMlIKL14AY/x4gUCKQoc7Jsv
3GZA2NtLByVp8RfFQ+Q7sA8IpmLyYi9elEWh339BhH2mMpRR
kn/xwp3uxQvfgBcvbmFf+W6/eOHE/uLFrv6LFwIJL14Q2ab8
/iT04sVTJEhCTMVVdz8VMUW18+6JF1Rfv2fh4uISpoGCAsUN
pWIMRfz169f0L99Rmdw3aDKaMWgoxCFFGT8qD5+8rkZuBp86
FupLdS4PvYcs9GwP5/nfDjfkCm8l1m0ZEeHjG+1gv8T5+0LB
FgX+n77owcX59yO2H/tLMLAK7d9vQqioINkm1HAAqv++cEFf
4f9+AHwnfekGVVrL1vj71Ua4r4QSf4EtgTqChOj/vKi4YYXy
7JSY/17EXkoUkJeiWhvK9L/qAWeP8zHEoYT4/s9LlJ+GCqIy
xKjTSfBPU2QiYDV/TcGX/afijBSc7zKMpgTFq6G+/y2XDauZ
gVshlPafij8OocgAYyvQ1O0kRf9bTglWcwwpfSfuPxW/MUUA
Qvs0Awtq//YiD1bzh4hoA/A/Fce8hXVio7BNVedvL8ZhNf/s
ApVJ/FNxHwmsE/ZqK4zFf3vxFVbz/+fD8yTi1xn2lPDWdMXj
aJBUyKivv6TB6wn+wcb89pRA3VHgoTL3cu4IsuDiw8dbIql2
OAhu3teuKD/s6/tNbwcd215q3qfT1GRBa7+hgaNMJkjDnoY2
98VqH9VtwdOnXV9j8jaMXzY1vfNoFHTaNZWNu/90uycGyDuf
gjDj/7dJuDSlnjd9/BVEjSM2u2OKkdaT6xN7xTue
And at this moment, I don't know how to process this text. Effectively it reads like puzzle text.
What is it?
This is a Base64 encoding of a PNG file called Sound decryptor.png.
Use any Base64 decoder to convert it to a file... Such as this one: http://download.cnet.com/Base64-Encoder-Decoder/3000-10250_4-10555647.html
This is Base64 encoded data.
The particular snippet in your question looks like the beginning of a ZIP-file (begins with the typical PK).
This is a base64-encoded ZIP archive, here's the start of it: PK...T#:{‘...[Samsung] - Test task - Sound decryptor.png.... (contains a PNG image, perhaps something else).
This seems to be a Base64 encoded PNG file. Could you post the entire file so we're able to try to decode it?
This looks like Base64 encoded text. Depending on the programming language you use, you should be able to find a function to decode it for you.
For Python, use base64.b64decode(text). For PHP, use base64_decode($text). Other environment have similar facilities.
Do this to decode the Base64 encoded data:
$ base64 -d original.file
P&T#:{üޗÂÁ+[Samsung] - Test task - Sound decryptor.pngìýeP\]×&¸÷ MÁ%8
(...)
$ base64 -d original.file > decoded.file
$ file decoded.file
decoded.file: Zip archive data
As it turns out to be a ZIP file, it can be unzipped by:
$ unzip decoded.file
Command base64 is in coreutils.