Questions tagged [base64]

Questions about encoding/decoding file or stdin by using base64

52 questions
43
votes
5 answers

How can I get a base64 encoded shaX on the cli?

sha1sum outputs a hex encoded format of the actual sha. I would like to see a base64 encoded variant. possibly some command that outputs the binary version that I can pipe, like so: echo -n "message" | | base64 or if it outputs it…
xenoterracide
  • 57,918
  • 74
  • 184
  • 250
15
votes
3 answers

base64 -d decodes, but says invalid input

Does anybody know why this is happening and how to fix it? me@box:~$ echo "eyJmb28iOiJiYXIiLCJiYXoiOiJiYXQifQ" | base64 -di {"foo":"bar","baz":"bat"}base64: invalid input
shwoseph
  • 315
  • 1
  • 2
  • 7
14
votes
1 answer

Can OpenSSL decode base64 data that does not contain line breaks?

I have two chunks of base64 data in a bash variable. The usual line breaks within the base64 data have been replaced by spaces and the variable is basically one very long one-line string. I can decode the two chunks of base64 data contained in the…
starfry
  • 7,302
  • 6
  • 47
  • 69
8
votes
1 answer

Why is 0x00 being deleted when assigning a base64 decoded string to a variable

I'm using a Mac. In Bash, I'm trying to decode a base64 string and then try to print the Hex value. I'm using base64 -d command and then assigning it to a variable. myText='YYN29+2wV2XRAHymIyhgytWuqY4atgHnIUFfXA7FPOA=' myTextBytes=$(echo -n…
SilleBille
  • 191
  • 5
8
votes
1 answer

How do you convert a base64 utf-8 encoded string to a binary file from bash?

Is there a tool that will do this in bash?
leeand00
  • 4,443
  • 10
  • 51
  • 78
8
votes
3 answers

What's the right way to base64 encode a binary file on CentOS 7?

I'm using CentOS 7 with bash shell. I thought base64-encoding a binary file would be as simple as [rails@server lib]$ cat mybinary.file | base64 > /tmp/output.base64 However, I notice when I look at the file length, it's not a multiple of…
Dave
  • 2,348
  • 21
  • 54
  • 84
6
votes
1 answer

How to extract first base64 code out of file?

On Linux I'm having text files and each contains 1 or 2 base64 blocks of code. Following is part of the file and 1 base64 block. Content-Transfer-Encoding:…
16851556
  • 201
  • 2
  • 11
5
votes
3 answers

Is it possible to convert linux salted sha512 password hash to LDAP format?

We have an LDAP server which stores passwords and other user data. The server is not used for authentication of client machines though but only for authentication of client apps. So users change their passwords locally on their clients. As long as…
user333869
  • 239
  • 3
  • 10
5
votes
3 answers

How do I decode a list of base64-encoded file names?

I have a list of base64-encoded file names in the pattern of {base64-encoded part here}_2015-11-12.pdf. I'm trying to decode that list of files and return it on the command line as another list, separated by newlines. Here's what I'm trying…
hourback
  • 303
  • 1
  • 3
  • 11
5
votes
1 answer

What is this seemingly base64 data set by setfattr?

I have written a short shell script that simply wraps setfattr in a slightly more convenient form for setting the extended attribute that corresponds to a free-text comment: #!/bin/sh test "$2" && setfattr -n user.xdg.comment -v "$2" "$1" getfattr…
user
  • 28,161
  • 13
  • 75
  • 138
4
votes
2 answers

Difference between wc -c and ${#}?

I've created script, where I encoded string 28 times with base64. Then I wanted to echo count of chars in outputted string. First I used ${#var} which gave me 34070. Then I tried on the same string script.sh | wc -c which gave me…
4
votes
1 answer

Javascript BTOA vs base64 in bash?

I need to convert a username and password combination into base64 before sending to an API. The javascript BTOA function is working for me, but when I try to use base64 command in bash I get slightly different results. Javascript: btoa("hello"); …
Philip Kirkbride
  • 9,816
  • 25
  • 95
  • 167
3
votes
4 answers

Replace a base64 value in a file in unix

I have a problem, I have a file test.txt that has a content like this: objectClass: CPM1 objectClass: CPM2 objectClass: CPM3 objectClass: CPM4 objectClass: CPZ objectClass: CP04s objectClass: CP0A objectClass: CP11 entryDS: 1 nodeId:…
3
votes
1 answer

running base64 encoded bash script gives me error

I have a bash script; the script is to generate a random number and have the user guess it. printf 'Guess the number (1-10) : ' read -r n randint=$(( ( RANDOM % 10 ) + 1 )) if [ $n = $randint ]; then echo "You Won !" else echo "Sorry, try again…
ghost21blade
  • 133
  • 6
3
votes
1 answer

bash: how do I write base64-encoded content into a file to specified line

I'm working on an "edgemax feature-wizard" which is kind of a plugin system. There are only three files allowed in a plugin tarball: a bash script as backend, a HTML file as frontend and a validation.json file for input validation from frontend, so…
1
2 3 4