Script for automatic encryption by shell

Hello, i'm just a new newbie and i'm happy to meet you, i think that is a good thing to present myself but i don't found a section for do that, and i will do it here.

Hello everyone, my name is Marco and i'm from Italy 19 years old and i'm n00b, i'm a MAC user (yeah don't kill me for that xD) and i hope to learn more about the Unix world, i have just a problem :frowning: i'm unfriendly with unix shell, she hates me and very many times i insult them, and i need someone that help me to make friendly the unix shell, i hope to find friends and someone that will like to give me his help. :slight_smile:

That is my stupid problem:

i have to encrypt one text file to base64 for 1024 times, and every time i crypt it, i have to add a word, like for example LOL= for every string, here a example:

encodemeLOL=  > ZW5jb2RlbWVMT0w9IA==LOL= > Wlc1amIyUmxiV1ZNVDB3OUlBPT1MT0w9LOL= > V2xjMWFtSXlVbXhpVjFaTlZEQjNPVWxCUFQxTVQwdzlMT0w9LOL= 

and i have to do that for 1024 times, now i had try to create a small script for unix shell:

echo �LOL=� >> /Users/Supermarco/Desktop/encrypt.txt && openssl -enc -base64 -in /Users/Supermarco/Desktop/encrypt.txt -out /Users/Supermarco/Desktop/lol2.txt && mv /Users/Supermarco/Desktop/lol2.txt encrypt.txt

i have tried also to do that

echo �LOL=� >> /Users/Supermarco/Desktop/encrypt.txt && openssl -enc -base64 -in /Users/Supermarco/Desktop/encrypt.txt -out /Users/Supermarco/Desktop/encrypt.txt

but i will check the text file and i see that all text was deleted.

don't worry, i have first put a text to crypt on the text before launch the command but i don't have got no results, can you tell me a correct command to launch for encrypt that text?

or better good, can you add on the script a command that will automatize the crypt for encrypting 1024 times without that i need to launch the command 1024 times? i hope that you have understand with my bad english. :slight_smile:

Have a nice day, and best regards

Marco

Hi Marco, thank you for the introduction and welcome to these forums.

Could you also post a sample of encrypt.txt ?

hi, thank you for replay. :slight_smile: sorry i were go to dinner, and until 40 minutes i will go to sleep because tomorrow i have to get up at the 7am :S however... on encrypt.txt i have write only: encodeme , it's just a text that i have to crypt...

for i in {1..1024}; do base64 -i encrypt.txt -o temp; mv -f temp encrypt.txt; done
for i in `seq 1024`; do base64 -i encrypt.txt -o temp; mv -f temp encrypt.txt; done
i=0; while (( i++ < 1024 )); do base64 -i encrypt.txt -o temp; mv -f temp encrypt.txt; done 

The above solutions are trivial. if you know more elegant one - please post it. Thanks

WOW thanks you very much! :smiley: it's perfect, but the problem is that i have to add the same word on every string i will generate...
mmh, really i don't think that i can know more elegant codes... for me... it's the same, i will be happy also with an ugly code. :asd:

with or without newline?

nono, i need it attached to the same text... for example:

encodemeLOL= crypt to ----> ZW5jb2RlbWVMT0w9IA==LOL= -----> Wlc1amIyUmxiV1ZNVDB3OUlBPT1MT0w9LOL= -----> V2xjMWFtSXlVbXhpVjFaTlZEQjNPVWxCUFQxTVQwdzlMT0w9LOL=

i go to sleep, i will return tomorrow, thank you very much to everyone and more thanks for the future answers, i will contribute to the community maybe asking more questions.

hey i have see that there isn't an off topic section, it's so sadly this thing :frowning:

yes i know i'm the most stupid person on the world, now i need to decrypt the same text but instead from crypt it 1024 times in base64 to decrypt it 1024 times... and for every decode i have to put the same word...

this is the example:

i=0; while (( i++ < 1024)); openssl -d base64 -i /Users/Supermarco/Desktop/a.txt -o temp; mv -f temp /Users/Supermarco/Desktop/a.txt; echo LOL= >> /Users/Supermarco/Desktop/a.txt; done

i also tried this:

i=0; while (( i++ < 1024 )); openssl base64 -d -in �/Users/Supermarco/Desktop/a.txt' -out �Users/Supermarco/Desktop/b.txt'; echo LOL= >> /Users/Supermarco/Desktop/a.txt

but there isn't no solution, when for encode that works, but for decode it won't work, i have tried for 2 hours but it doesn't want to start :frowning: and there aren't error messages, really i have no idea of what i have to do...