Operating System - HP-UX
1832890 Members
2206 Online
110048 Solutions
New Discussion

Re: Error with crypt command

 
SOLVED
Go to solution
Alfonso Plaza
New Member

Error with crypt command

Hi all,
I`d like encrypt a shell variable with crypt, but i get the following error:

$ word_crpt=`echo "Hello word"|crypt "pass"`
crypt: cannot generate key

Any idea.

Thanks.

7 REPLIES 7
Bruno Ganino
Honored Contributor
Umapathy S
Honored Contributor

Re: Error with crypt command

crypt can be used to encrypt files and not variables.

check the man page
Arise Awake and Stop NOT till the goal is Reached!
Alfonso Plaza
New Member

Re: Error with crypt command

Ok. but when i do the following its run ok.
$ echo "uncrypt"|crypt "pass"
ù⠰`öô¶$

And i run the next command in a Sun Solaris system and it run ok.

$ echo "uncrypt" |crypt "pass"
ù⠰`öô¶
$
$ palabra=`echo "uncrypt" |crypt "pass"`
$ echo $palabra
ù⠰`öô¶
$

And the save the text crypted to a file and pass de contain to a variable its not recommendes f
Mike Stroyan
Honored Contributor

Re: Error with crypt command

It works fine for me.
It looks like crypt was unable to run /usr/lbin/makekey.
Perhaps it ran out of a resource such as nproc or maxuproc.
You could try that command in a shell that you
ran under tusc to watch for failing system calls.

$ tusc -fn -o crypt.tusc /usr/bin/sh
$ word_crpt=`echo "Hello word"|crypt "pass"`
$ exit
$ vi crypt.tusc

You can get tusc from
http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/tusc-7.5/
Steven E. Protter
Exalted Contributor

Re: Error with crypt command

I'm getting the same results as you.

maxuprc and nproc are fine.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Mike Stroyan
Honored Contributor
Solution

Re: Error with crypt command

Interesting. I was working for me because I
have /usr/dt/bin/dtksh as my login shell.
The problem is that crypt is using wait() to
wait for makekey, but it is not checking the
process id when wait returns. In the pipe
command under most shells the crypt process
is continuing after the wait() call returns
with the process id of the forked shell
process that did echo builtin.

You can work around crypt's problem by making
the echo side of the pipe a little slower to
complete. That will allow the makekey to
finish first.

crypt=`echo "Hello word";sleep 1 |crypt "pass"`
Mike Stroyan
Honored Contributor

Re: Error with crypt command

Hmm, that needs parentheses to keep the output
of the echo command heading through the pipe.

word_crpt=`(echo "Hello word";sleep 1 ) |crypt "pass"`