Issues Masking(Encrypting) a string


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issues Masking(Encrypting) a string
# 1  
Old 10-05-2016
Hammer & Screwdriver Issues Masking(Encrypting) a string

Hi,

Code:
echo "mypassword" | crypt "tom"

But this is giving me some unreadable strange looking characters / symbols never seen before which I cant even copy and save in a file.

Code:
SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v

Can you help me with encrypting the password "mypassword" in readable string ?

Last edited by mohtashims; 10-05-2016 at 12:29 PM..
# 2  
Old 10-05-2016
Isn't that exactly what you want to do - encrypt some clear text into something unreadable to the world that can be retrieved only if the password is known? Don't copy and paste the result; save it in a file immediately. That file can be decrypted by applying crypt "tom" again.

Warning (from man crypt):
Quote:
The DES algorithm itself has a few quirks which make the use of the crypt() interface a very poor choice for anything other than password authentication. If you are
planning on using the crypt() interface for a cryptography project, don't do it: get a good book on encryption and one of the widely available DES libraries.
# 3  
Old 10-05-2016
Can you please confirm if crypt can do what I want it to do ?

openssl can be used with RSA algo and it gives encrypted text in readable format which can also be copied.

It's a very naïve and personal requirement. Not caring too much about it being full proof.
# 4  
Old 10-06-2016
So, what do you want it to do overall? (not just the one line)

I would expect that echo "mypassword" | crypt "tom" > encrypted_file will write your encrypted password into a file just fine, from where you can read it back, but what is the purpose?

The display you see will depend on a combination of a number of factors, such as locale, character sets for the terminal type defined, character set of the display you are using etc. You cannot reliably use the screen to just copy & paste the display for use elsewhere. You would need to copy the file of get it into a variable to use somehow.

If your script to retrieve it has the decryption password tom, the source file name and the method to extract it, then anyone who can read the code can get the password.

It's a common conundrum - how do you encrypt something and automate the decryption without just sharing the decryption.


If you can share a little more about the overall plan of your code, then we might be able to suggest something suitable.



Kind regards,
Robin
# 5  
Old 10-06-2016
Quote:
Originally Posted by rbatte1
So, what do you want it to do overall? (not just the one line)

I would expect that echo "mypassword" | crypt "tom" > encrypted_file will write your encrypted password into a file just fine, from where you can read it back, but what is the purpose?

The display you see will depend on a combination of a number of factors, such as locale, character sets for the terminal type defined, character set of the display you are using etc. You cannot reliably use the screen to just copy & paste the display for use elsewhere. You would need to copy the file of get it into a variable to use somehow.

If your script to retrieve it has the decryption password tom, the source file name and the method to extract it, then anyone who can read the code can get the password.

It's a common conundrum - how do you encrypt something and automate the decryption without just sharing the decryption.


If you can share a little more about the overall plan of your code, then we might be able to suggest something suitable.



Kind regards,
Robin
I just need the password to look visibly different than the actual password.

The encrypted password should be a string readable to humans.

So, I just need it to mask the password.
# 6  
Old 10-06-2016
Code:
echo "mypassword" | base64
bXlwYXNzd29yZAo=

These 2 Users Gave Thanks to RudiC For This Post:
# 7  
Old 10-06-2016
However you do it, it will be easy to reverse the process, so what is actually the purpose of encrypting it?



Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. High Performance Computing

Encrypting interconnect

Hi, i've got a qusetion regarding interconnect of compute nodes. In our company we are running a Simulation Cluster which is administrated by the Simulation department. Now our central IT requires to encrypt the interconnect of the compute nodes. Does anybody in that business encrypt... (3 Replies)
Discussion started by: fiberkill
3 Replies

2. Shell Programming and Scripting

Encrypting password

Hello All, I need to accept a password from the user and validate it, without having to hard-code it anywhere. Any ideas? (3 Replies)
Discussion started by: optimus_1
3 Replies

3. Shell Programming and Scripting

Encrypting the password

Iam using the teradata... and running the scripts in unix, I wan to encrypt the teradata password in Unix... my hostname is : bprod usename: KRN777 passwrd: passwrd can ant one tell me the exact command to encrypth the passwrd.... thanks, (5 Replies)
Discussion started by: nani1984
5 Replies

4. Shell Programming and Scripting

String Comparison Issues

Hello there. I am trying to write a simple script that pulls the date on which the system was last shutdown (stored in a file called 'last_shutdown') and today's date (the days only) and compares the two. If the two match, I want it to perform some tasks. That is, if today is 31 May 2010 and the... (2 Replies)
Discussion started by: ksk
2 Replies

5. Shell Programming and Scripting

Shell script for encrypting a string

Hi, I am new to Unix server and shell scripting.I want to encrypt username/password using shell script.I know that there's a Crypt command to encrypt but it is not installed in my unix server and cannot be installed due to some reason.So i want the shell script of the crypt command or is there... (3 Replies)
Discussion started by: Princessp
3 Replies

6. Shell Programming and Scripting

Issues with string replacement

I posted this issue a week or so ago and I still cant get the script to work. Here is what I have so far and what Im trying to do. #!/bin/ksh old="$1" new="$2" file=$3 grep $1 $3 > /dev/null if ;then cp $3 ${3}.bak sed "s/$1/$2/g" $3 > ${3}~ mv ${3}~ ${3} fithe script is... (5 Replies)
Discussion started by: gordonheimer
5 Replies

7. Shell Programming and Scripting

Masking Content of a String

Hello, I need to know that whether a content of a string can be hidden or masked inside a shell script. My Sample Code is given below <Code> #!/usr/bin/ksh Userid=test DB=temp Passwd=`java Decryption test` # The Above command will get the encryped password for "test" user id and store... (2 Replies)
Discussion started by: maxmave
2 Replies

8. Solaris

Encrypting a script......

Hiiiiii..... every one..... I have written a script, and i want to make that script confidential.So that, only i can see that script. I am using " crypt " command in solaris 9, to encrypt that script.But when i am executing this... (6 Replies)
Discussion started by: prashantshukla
6 Replies

9. UNIX for Dummies Questions & Answers

masking or encrypting in shell script

Hi folks, I am writing a script which asks the user to enter a user name and password to telnet and logon to some other machine. The script promts the user to enter the login name and password as below. echo "Enter the login name to be used to login on the machine" read login echo "Enter the... (4 Replies)
Discussion started by: dshrish
4 Replies

10. AIX

Encrypting password

I have a strange question for someone regarding the AIX 5.2 environment. Here is the scenerio: I have a script that is running a menu full of options. 1. I like food 2. I don't like food Enter Option:_ Enter userID:_ Enter Password:_ (The menu is conversational only so go with me on... (6 Replies)
Discussion started by: Justman
6 Replies
Login or Register to Ask a Question