HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Encrypting a long password from command line
Operating System - HP-UX
1834101
Members
2869
Online
110063
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2006 11:06 AM
09-08-2006 11:06 AM
I have searched the forums for this but could not figure out how to get an encrypted password for passwords of longer than 8 characters, to be used on trusted systems
For 8 characters long passwords, I can use
echo "abcd1234" | /usr/lib/makekey
and it works fine but due to my company regulations, the password I am trying to make should be at least 15 characters or more.
I have found Bill Hassel's c program below
#include
#include
/* 1st param is the desired password */
/* A random seed (2 chars) will be */
/* automatically chosen. */
/* For good passwords: */
/* Use random chars, mixed apha- */
/* numerics and MiXeD CaSe for */
/* better protection. */
main(argc, argv)
int argc;
char *argv[];
{
char salt[3];
char *EncryptedPasswd;
int CheckRand;
int Fixup;
int SeedChar;
printf("\nUsage: %s\n",argv[0]);
/* Generate a random starting point for seed charcaters */
srand(time(NULL));
for ( SeedChar = 0; SeedChar <= 1; SeedChar++)
{
CheckRand = 46 + rand() % 76; /* random from 46 to 122 */
Fixup = 7 + rand() % 13; /* random from 7 to 20 */
salt[SeedChar] = toascii(((CheckRand >= 58 && CheckRand <= 64)
|| (CheckRand >= 91 && CheckRand <= 96)
? CheckRand + Fixup : CheckRand));
}
EncryptedPasswd=crypt(argv[1], salt);
printf("\nRequested pw= %s, Seed= %s, encrypted pw= %s\n",
argv[1], salt, EncryptedPasswd);
}
and hoping that I could substitue crypt with bigcrypt to accomplish this but it was a bust. Since I am not a c programmer, I did not know what I was doing, so failure to compile was not a heartbreak.
Can anybody suggest me how to crypt a 15 or more cleartext password on the command line ?
Thanks.
For 8 characters long passwords, I can use
echo "abcd1234" | /usr/lib/makekey
and it works fine but due to my company regulations, the password I am trying to make should be at least 15 characters or more.
I have found Bill Hassel's c program below
#include
#include
/* 1st param is the desired password */
/* A random seed (2 chars) will be */
/* automatically chosen. */
/* For good passwords: */
/* Use random chars, mixed apha- */
/* numerics and MiXeD CaSe for */
/* better protection. */
main(argc, argv)
int argc;
char *argv[];
{
char salt[3];
char *EncryptedPasswd;
int CheckRand;
int Fixup;
int SeedChar;
printf("\nUsage: %s
/* Generate a random starting point for seed charcaters */
srand(time(NULL));
for ( SeedChar = 0; SeedChar <= 1; SeedChar++)
{
CheckRand = 46 + rand() % 76; /* random from 46 to 122 */
Fixup = 7 + rand() % 13; /* random from 7 to 20 */
salt[SeedChar] = toascii(((CheckRand >= 58 && CheckRand <= 64)
|| (CheckRand >= 91 && CheckRand <= 96)
? CheckRand + Fixup : CheckRand));
}
EncryptedPasswd=crypt(argv[1], salt);
printf("\nRequested pw= %s, Seed= %s, encrypted pw= %s\n",
argv[1], salt, EncryptedPasswd);
}
and hoping that I could substitue crypt with bigcrypt to accomplish this but it was a bust. Since I am not a c programmer, I did not know what I was doing, so failure to compile was not a heartbreak.
Can anybody suggest me how to crypt a 15 or more cleartext password on the command line ?
Thanks.
Solved! Go to Solution.
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2006 12:42 PM
09-08-2006 12:42 PM
Solution
You were close. Essentially you were missing two header files and the correct library to link with:
1) Download the attached adaptation of Bill's program, pw.c, to your PC.
2) Transfer pw.c from your PC to a UNIX box using an FTP ASCII put.
3) Compile/link like this:
cc pw.c -lsec -o pw
4) Execute like this:
PWHASH=$(pw "MickeyMouse99!")
echo "Hash = \"${PWHASH}\""
I modified it to simply output the password hash output of bigcrypt rather than displaying the plaintext and salt also.
NOTE: Real UNIX guys (and gals) know at least some C.
1) Download the attached adaptation of Bill's program, pw.c, to your PC.
2) Transfer pw.c from your PC to a UNIX box using an FTP ASCII put.
3) Compile/link like this:
cc pw.c -lsec -o pw
4) Execute like this:
PWHASH=$(pw "MickeyMouse99!")
echo "Hash = \"${PWHASH}\""
I modified it to simply output the password hash output of bigcrypt rather than displaying the plaintext and salt also.
NOTE: Real UNIX guys (and gals) know at least some C.
If it ain't broke, I can fix that.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP