Script for automatic encryption by shell


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script for automatic encryption by shell
# 1  
Old 05-27-2014
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 Smilie 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. Smilie

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:

Code:
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:

Code:
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

Code:
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. Smilie

Have a nice day, and best regards

Marco

Last edited by Scrutinizer; 05-27-2014 at 02:13 PM.. Reason: code tags
# 2  
Old 05-27-2014
Hi Marco, thank you for the introduction and welcome to these forums.

Could you also post a sample of encrypt.txt ?
# 3  
Old 05-27-2014
hi, thank you for replay. Smilie 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...
# 4  
Old 05-27-2014
Code:
for i in {1..1024}; do base64 -i encrypt.txt -o temp; mv -f temp encrypt.txt; done

Code:
for i in `seq 1024`; do base64 -i encrypt.txt -o temp; mv -f temp encrypt.txt; done

Code:
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
This User Gave Thanks to useretail For This Post:
# 5  
Old 05-27-2014
WOW thanks you very much! Smilie 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:
# 6  
Old 05-27-2014
with or without newline?
# 7  
Old 05-27-2014
nono, i need it attached to the same text... for example:

Code:
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 Smilie

Last edited by supermarco2020; 05-27-2014 at 04:59 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automatic input "yes" in a shell script

Hi All, I need a favour. I have a file called "redhat_servers.txt" containing some server names line by line. When I try to ssh to each server, and I have already done with ssh key-gen stuff. Now, for first time if I do ssh .. I need to type yes I have more than 400 servers...it will take... (4 Replies)
Discussion started by: kumar85shiv
4 Replies

2. Cybersecurity

File encryption tools with MAC address as an encryption key

Hi all, I'm looking for secure file encryption tools that use MAC address as encryption key. FYI, I'm using Red Hat Enterprise Linux OS. For example: when A wants to send file to B A will encrypt the file with B's computer MAC/IP address as an encryption key This file can only be decrypted... (2 Replies)
Discussion started by: sergionicosta
2 Replies

3. Shell Programming and Scripting

Giving automatic multiple Input to a tool from shell script

Hi, Please help me,its urgent. I have a tool that i want to run from a shell script. When we run the tool it will ask the user choice to add or delete. When user enter the choice it will then ask how many units he want to delete or add and will add or delete accordingly. Now I want to... (1 Reply)
Discussion started by: saket18@ymail.c
1 Replies

4. Shell Programming and Scripting

why my encryption shell script not working

I am trying to write a shell script which will use a text file as an argument to produce pgp encryted file. Shell script name: encryptext.sh This is the code of encryptext.sh #!/usb/bin/ksh file=$1 cd /home/project/source gpg --verbose --armour --encrypt --recipient "IMS_L2" --output... (2 Replies)
Discussion started by: shanbalao
2 Replies

5. Shell Programming and Scripting

Automatic running of Shell scripts

Hi, I have this problem of merging 2 shell scripts and run it one after the other. For eg: script A runs to give OutputA. This OutputA should become the input of script B which will run to give OuputB. Now this has to happen automatically i.e, script A and script B should run consecutively one... (1 Reply)
Discussion started by: Vindhyaauri
1 Replies

6. Shell Programming and Scripting

Shell script for sending automatic email to personal mail id

hi guys, I need a shell script to send mail automatically to my personal mail id like xxxx@hotmail.com but while experimenting with "mail" command I faced following problems. cat text1.txt | mail -s 'test mail' xxxx@hotmail.com command successfully executed but while checking for... (4 Replies)
Discussion started by: rrd1986
4 Replies

7. Shell Programming and Scripting

automatic execution of shell script

Dear All, I want to execute a shell script,whlie system is booting. I was try using /etc/rc.d/rc.local file but its not working. (1 Reply)
Discussion started by: rajamohan
1 Replies

8. Shell Programming and Scripting

Automatic download of csv file using a shell script

I want to automatically download a CSV file daily which can be found here: http://www.londonstockexchange.com/en-gb/pricesnews/prices/coveredwarrants/search.htm and the link is named "Click to download covered warrants (100Kb)" onthe right hand side. What commands can I use to invoke clicking... (1 Reply)
Discussion started by: figaro
1 Replies

9. UNIX for Dummies Questions & Answers

File encryption/Key encryption ????

My dilemma, I need to send, deemed confidential, information via e-mail (SMTP). This information is sitting as a file on AIX. Typically I can send this data as a e-mail attachment via what we term a "mail filter" using telnet. I now would like to somehow encrypt the data and send it to a e-mail... (1 Reply)
Discussion started by: hugow
1 Replies
Login or Register to Ask a Question