Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Script for automatic encryption by shell Post 302903406 by supermarco2020 on Tuesday 27th of May 2014 12:17:26 PM
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
 

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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

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

7. 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

8. 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

9. 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
ENCRYPT(3)						     Linux Programmer's Manual							ENCRYPT(3)

NAME
encrypt, setkey, encrypt_r, setkey_r - encrypt 64-bit messages SYNOPSIS
#define _XOPEN_SOURCE #include <unistd.h> void encrypt(char block[64], int edflag); #define _XOPEN_SOURCE #include <stdlib.h> void setkey(const char *key); #define _GNU_SOURCE #include <crypt.h> void setkey_r(const char *key, struct crypt_data *data); void encrypt_r(char *block, int edflag, struct crypt_data *data); Each of these requires linking with -lcrypt. DESCRIPTION
These functions encrypt and decrypt 64-bit messages. The setkey() function sets the key used by encrypt(). The key argument used here is an array of 64 bytes, each of which has numerical value 1 or 0. The bytes key[n] where n=8*i-1 are ignored, so that the effective key length is 56 bits. The encrypt() function modifies the passed buffer, encoding if edflag is 0, and decoding if 1 is being passed. Like the key argument, also block is a bit vector representation of the actual value that is encoded. The result is returned in that same vector. These two functions are not reentrant, that is, the key data is kept in static storage. The functions setkey_r() and encrypt_r() are the reentrant versions. They use the following structure to hold the key data: struct crypt_data { char keysched[16 * 8]; char sb0[32768]; char sb1[32768]; char sb2[32768]; char sb3[32768]; char crypt_3_buf[14]; char current_salt[2]; long int current_saltbits; int direction; int initialized; }; Before calling setkey_r() set data->initialized to zero. RETURN VALUE
These functions do not return any value. ERRORS
Set errno to zero before calling the above functions. On success, it is unchanged. ENOSYS The function is not provided. (For example because of former USA export restrictions.) CONFORMING TO
The functions encrypt() and setkey() conform to SVr4, SUSv2, and POSIX.1-2001. The functions encrypt_r() and setkey_r() are GNU exten- sions. NOTES
In glibc 2.2 these functions use the DES algorithm. EXAMPLE
You need to link with libcrypt to compile this example with glibc. To do useful work the key[] and txt[] arrays must be filled with a use- ful bit pattern. #define _XOPEN_SOURCE #include <unistd.h> #include <stdlib.h> int main(void) { char key[64]; /* bit pattern for key */ char txt[64]; /* bit pattern for messages */ setkey(key); encrypt(txt, 0); /* encode */ encrypt(txt, 1); /* decode */ } SEE ALSO
cbc_crypt(3), crypt(3), ecb_crypt(3), feature_test_macros(7) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. 2003-04-04 ENCRYPT(3)
All times are GMT -4. The time now is 06:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy