How Can I Encode a Variable in Base64 28 Times in Bash?

0
9
Asked By TechTornado92 On

I'm trying to create a bash script where I need to encode a variable called "var" in base64 28 times. After the loop, I want to store the character count of the 28th encoded string into a variable called "salt." However, I've been struggling to get this to work, and nothing seems to produce the right result. Here's the context of my script and the decryption function I'm working with...

3 Answers

Answered By BashNewb123 On

It seems like you're trying to obfuscate something. Just to clarify, could you tell us what the end goal of this script is? I'm a bit new to bash and this looks like it could be tricky!

Answered By ScriptingSavant On

To encode your variable in base64 28 times, you can use this loop:

```bash
for i in {1..28}; do
var="$(echo "${var}" | base64)"
done
salt=${#var}
```
Just keep in mind that newline characters from `echo` might throw off your results!

Answered By CodeCrusher77 On

You might want to use ShellCheck to help catch errors—looks like you're missing a lot of quotes in your script! They can help clarify the commands and prevent issues during execution.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.