Sponsored Content
Full Discussion: Encrypt and decrypt a string
Top Forums Shell Programming and Scripting Encrypt and decrypt a string Post 302505449 by rohan10k on Thursday 17th of March 2011 02:17:59 AM
Old 03-17-2011
Encrypt and decrypt a string

Hi, I want to encrypt and decrypt a string(database password) which will be used in my scripts.
encrypt the string while storing in a file and while using it in other scripts
it should decrypt.
i tried below method. As it can decrypt easily, it is not recommended.
Code:
encrypt=`perl -e 'print unpack "H*","yourpassword"'`
descrpt=`perl -e 'print pack "H*","encrypted password"'`

Could you please suggest any other methods for this.
My Unix environment details are SunOS 5.10 Generic_118833-36

Thanks in advance.

Last edited by Franklin52; 03-17-2011 at 06:43 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Encrypt & Decrypt a String

Hi Everybody, I have a script that telnet another system. For some reasons, this is should be done by "root", so the root password has been written explicitly in this script, which mean any body read this script will know the root password of the other system. I think the solution is to write... (6 Replies)
Discussion started by: aldowsary
6 Replies

2. Shell Programming and Scripting

encrypt and decrypt password

how do i encrypt and decrypt a password (2 Replies)
Discussion started by: sanwish
2 Replies

3. Solaris

Decrypt Des file - then encrypt

Help.. I need to decrypt a file that was encrypted using DES 56 Bit. I have the encryption key and the block size used but no idea what utility to use.. I then need to encrypt the file using pgp and another key I have.. againt I dont know what utility to use. I am running solaris 9 .... ... (0 Replies)
Discussion started by: frustrated1
0 Replies

4. Shell Programming and Scripting

Encrypt and Decrypt script

Dear Experts, I am using one script name :volume.sh and its written in bash shell script. I just want to encrypt the script so that any one else cannot see it. please tell me the commands how to encrypt the script as well as to decrypt it. Regards, SHARY (9 Replies)
Discussion started by: shary
9 Replies

5. Shell Programming and Scripting

How to encrypt and decrypt a file

How to encrypt and decrypt a file using unix Command? Can any one help me? (2 Replies)
Discussion started by: laknar
2 Replies

6. Shell Programming and Scripting

Encrypt/Decrypt string with rsa keys

Hello, I wanted to know if there was a way to encrypt a string, not a file using openssl and then decrypt it? I cant seem to get it to work. This is what I have been trying but I'm not having much luck. encTxt=`echo "$1" | openssl dgst -sha1 -binary | openssl rsautl -sign -inkey... (1 Reply)
Discussion started by: tjones1105
1 Replies

7. Shell Programming and Scripting

Encrypt and Decrypt

I have script for all oracle prod db. I have hard coded the username / password. I need a mechanism to encode and decode the username / password in a shell script. Another challenge is I use the username and password in a Select command for oracle DB. How can call the decrypted... (2 Replies)
Discussion started by: ilugopal
2 Replies

8. Programming

Encrypt and Decrypt file using RIJNDAEL-128

Hi All, Can I use MCRYPT - (RIJNDAEL-128) / CBC mode to encrypt and decrypt a file? I am trying to find some sample C program on internet, which will encrypt and decrypt a file. But was not able to find any thing. Can some help me with the programming. Thanks. (1 Reply)
Discussion started by: Shre
1 Replies

9. Shell Programming and Scripting

Encrypt and decrypt the password in a Shell Script

Hello, I have the following UNIX shell script which connects to the teradata database and executes the SQL Queries. For this, I am passing database name, username and password. I don't want to reveal my password to anyone. So, is there any way that I can encrypt my password and read the... (2 Replies)
Discussion started by: ronitreddy
2 Replies

10. UNIX for Beginners Questions & Answers

Encrypt and Decrypt a File with Password

Hello, I have few files on unix which are payroll related and I need them to encrypt with password so others wouldn't see the data. I use ETL tool and would like to know the unix command that does encryption/decryption to use in the ETL. Thank you, Sri (3 Replies)
Discussion started by: eskay
3 Replies
crypt(3)						     Library Functions Manual							  crypt(3)

Name
       crypt, crypt16, setkey, encrypt - DES encryption

Syntax
       char *crypt(key, salt)
       char *key, *salt;

       char *crypt16(key, salt)
       char *key, *salt;

       void setkey(key)
       char *key;

Description
       The  subroutine is the password encryption routine.  It is based on the NBS Data Encryption Standard, with variations intended to frustrate
       use of hardware implementations of the DES for key search.

       The first argument to is normally a user's typed password.  The second is a 2-character string chosen from the set [a-zA-Z0-9./].  The salt
       string  is  used to perturb the DES algorithm in one of 4096 different ways, after which the password is used as the key to encrypt repeat-
       edly a constant string.	The returned value points to the encrypted password, in the same alphabet as the salt.	The first  two	characters
       are the salt itself.

       The subroutine is identical to the function except that it will accept a password up to sixteen characters in length. It generates a longer
       encrypted password for use with enhanced security features.

       The other entries provide primitive access to the actual DES algorithm.	The argument of is a character array of length 64 containing  only
       the characters with numerical value 0 and 1.  If this string is divided into groups of 8, the low-order bit in each group is ignored, lead-
       ing to a 56-bit key which is set into the machine.

       The argument to the entry is likewise a character array of length 64 containing 0s and 1s.  The argument array is modified in  place  to  a
       similar	array  representing the bits of the argument after having been subjected to the DES algorithm using the key set by If edflag is 0,
       the argument is encrypted; if non-zero, it is decrypted.

Restrictions
       The return values from and point to static data areas whose content is overwritten by each call.

Environment
   Default Environment
       In the default environment on systems that do not have the optional encryption software installed the function expects  exactly	one  argu-
       ment,  the data to be encrypted. The edflag argument is not supplied and there is no way to decrypt data.  If the optional encryption soft-
       ware is installed the function behaves as it does in the POSIX environment.  The syntax for the default environment follows:
	    void encrypt(block)
	    char *block;

   POSIX Environment
       In the POSIX environment the encrypt function always expects two arguments.  The function will set errno to ENOSYS and return if edflag	is
       non-zero and the optional encryption software is not present.  The syntax for the POSIX environment follows:
	    void encrypt(block, edflag)
	    char *block;
	    int edflag;

       In all cases the function will set errno to ENOSYS and return if the optional encryption software is not present.

See Also
       login(1), passwd(1), yppasswd(1yp), getpass(3), auth(5), passwd(5), passwd(5yp)
       ULTRIX Security Guide for Users and Programmers

																	  crypt(3)
All times are GMT -4. The time now is 06:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy