Comment on Is there a self-hosted project that does base64 url decoding in a privacy respecting fashion?
hendrik@palaver.p3x.de 1 day ago
There's base64 -d
on the command line.
Comment on Is there a self-hosted project that does base64 url decoding in a privacy respecting fashion?
hendrik@palaver.p3x.de 1 day ago
There's base64 -d
on the command line.
ReedReads@lemmy.zip 1 day ago
Right but the
/
in the url trips it up and I’d like to just copy/paste the full url and have it spit out the proper, decoded link.ExFed@programming.dev 1 day ago
The
/
character isn’t a part of the base64 encoding. In fact, only one part of the URL looks like base64. No plain base64 tool (whether via CLI, self-hosted, or otherwise) will be able to decode an entire URL like that. You’ll first need to parse the URL to isolate the base64 part. This is literally solved with a single line of bash:echo "https://link.sfchronicle.com/external/41488169.38548/aHR0cHM6Ly93d3cuaG90ZG9nYmlsbHMuY29tL2hhbWJ1cmdlci1tb2xkcy9idXJnZXItZG9nLW1vbGQ_c2lkPTY4MTNkMTljYzM0ZWJjZTE4NDA1ZGVjYSZzcz1QJnN0X3JpZD1udWxsJnV0bV9zb3VyY2U9bmV3c2xldHRlciZ1dG1fbWVkaXVtPWVtYWlsJnV0bV90ZXJtPWJyaWVmaW5nJnV0bV9jYW1wYWlnbj1zZmNfYml0ZWN1cmlvdXM/6813d19cc34ebce18405decaB7ef84e41" | cut -d/ -f6 | base64 -d
ReedReads@lemmy.zip 1 day ago
| cut -d/ -f6 |
means? I assume thecut
is the parsing? But maybe that is wrong? Would love to learn how to learn this.krnl386@lemmy.ca 17 hours ago
Try explainshell.com - you can paste in any oneliner and the site will parse it and explain each part.
30p87@feddit.org 21 hours ago
cut --help
andman cut
can teach you more than anyone here.But: “|” takes the output of the former command, and uses it as input for the latter. So it’s like copying the output of “echo […]”, executing “cut -d ‘/’ -f 6”, and pasting it into that. Then copy the output of “cut”, execute “base64 -d” and paste it there. Except the pipe (“|”) automates that on one line.
And yes, cut takes a string (so a list of characters, for example the url), split’s it at what -d specifies (eg. cut -d ‘/’ splits at “/”), so it now internally has a list of strings, “https:”, “”, “link.sfchronicle.com”, “external”, 41488169.38548", “aHR0cHM6Ly93d3cuaG90ZG9nYmlsbHMuY29tL2hhbWJ1cmdlci1tb2xkcy9idXJnZXItZG9nLW1vbGQ_c2lkPTY4MTNkMTljYzM0ZWJjZTE4NDA1ZGVjYSZzcz1QJnN0X3JpZD1udWxsJnV0bV9zb3VyY2U9bmV3c2xldHRlciZ1dG1fbWVkaXVtPWVtYWlsJnV0bV90ZXJtPWJyaWVmaW5nJnV0bV9jYW1wYWlnbj1zZmNfYml0ZWN1cmlvdXM” and “6813d19cc34ebce18405decaB7ef84e41”, and from that list outputs whatever is specified by -f (so eg. -f 6 means the 6th of those strings. And -f 2-3 means the 2nd to 3rd string. And -5 means everything up to and including the fifth, and 3- means everything after and including the third).
But all of that is explained better in the manpage (man cut). And the best way to learn is to just fuck around. So
echo “t es t str i n g, 1” | cut …
and try various arguments.feedorimid@lemmynsfw.com 1 day ago
Cut into fields based on the delimiter (// in this case). The “-f6” selects which field you want.
ccryx@discuss.tchncs.de 19 hours ago
You can use
man cut
to read a program’s manual page. Appending–help
(without any other arguments will often produce at least a short description of the program and list the available options.hendrik@palaver.p3x.de 1 day ago
Well, the URL is a bit weird.
echo "aHR0cHM6Ly93d3cuaG90ZG9nYmlsbHMuY29tL2hhbWJ1cmdlci1tb2xkcy9idXJnZXItZG9nLW1vbGRzCg" | base64 -d
gives me your string. But there are a few characters off at the end. And then there are 176 characters left. I suppose the underscore is some delimiter. The rest is:
echo "c2lkPTY4MTNkMTljYzM0ZWJjZTE4NDA1ZGVjYSZzcz1QJnN0X3JpZD1udWxsJnV0bV9zb3VyY2U9bmV3c2xldHRlciZ1dG1fbWVkaXVtPWVtYWlsJnV0bV90ZXJtPWJyaWVmaW5nJnV0bV9jYW1wYWlnbj1zZmNfYml0ZWN1cmlvdXM" | base64 -d
"sid=6813d19cc34ebce18405deca&ss=P&st_rid=null&utm_source=newsletter&utm_medium=email&utm_term=briefing&utm_campaign=sfc_bitecurious"
ReedReads@lemmy.zip 1 day ago
I really appreciate all of the time and effort you spent on this url. You’re right, the url is weird, which is why I thought it was a good example.
But you nailed it with this last sentence. Especially when one is on mobile.
Thanks for replying again.
hendrik@palaver.p3x.de 23 hours ago
I know. Guess I mainly wanted to say your given solution isn't the entire story and the potential tool should decode the parameters as well, they might or might not be important. I'm often at the computer and I regularly do one-off tasks this way... But I'm aware it might not be an one-off task to you and you might not have a Linux terminal open 24/7 either 😉 Hope some of the other people have what you need. And btw... since I clicked on a few of the suggestions: I think URL encoding is a different thing, that's with all the percent signs and not base64 like here.
carl_dungeon@lemmy.world 1 day ago
Just put it in quotes?
SnotFlickerman@lemmy.blahaj.zone 1 day ago
This is the internet, maybe build it yourself instead of demanding others do the work for you?
You could also just as easily only paste in the encoded part and put it back into the link yourself.
ReedReads@lemmy.zip 1 day ago
No one is demanding anything. I’m simply stating my preferred solution, which would work on both mobile and desktop, and asking if anyone knows if that solution or something similar already exists.
Nothing suggested so far will properly decode the link that I’ve included above.
But there is no reason to build something duplicative if a solution is already out there. Hence, the post.
GreenKnight23@lemmy.world 1 day ago
you strike me as a competent developer but you lack the experience with Linux.
install xclip, then copy your URL and use the following command.
base64 -d "$(xclip -o)"
there’s probably a better way but I’m just remembering off the top of my head.
could probably pipe it into something that would spit it out with each param on new lines but you’ll need to google that.