• C

Password Encryption

Hi,

    Can anyone help me as to how to use the unix "crypt"
command in my password ????

    All I want to do is encrypt a password and then
decrypt it whenever necessary. Does anyone know what I
can use for this simple routine. Is there anything Simple
available on the web ???

   I will appreciate any help.

Thank You
singhtajAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

e4monschCommented:
There is a program available called Crack 4.0 (or 5.0) for Unix. This program allows you to crack passwords. It is very good and is used by system adminstrators worldwide for verifying Unix security. You can find it on http://www.shareware.com in the section Unix Most Popular.

By the way. Unix passwords cannot be decrypted due to a trap-door algorithm during encryption. Unix test passwords in the crypted state: You enter the password, it gets encrypted and is then compared with the crypted password in the password file.

There for when you crack password you test a large set of passwords(dictionaries) by crypting and comparing it with the crypted entry in the passfile.

If you have further questions feel free to ask further questions.

Regards Ian
0
e4monschCommented:
By the way: Crack 5.0 is available in Source code. So you can look into how it's done.
0
singhtajAuthor Commented:
Are you sure its under shareware.com, because I am unable
to find it.
Can you give me the exact site please.
Thanks

0
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

e4monschCommented:
http://search.shareware.com/code/engine/File?archive=linux&file=system%2fadmin%2fcrack_41%2etgz&size=401169

There is a new version available, but haven't found it on shareware.com

0
singhtajAuthor Commented:
Crack looks like very complicated.

Is there anything simpler out there...


0
staggartCommented:
I think I can help you, but I am unclear on what you are trying to do.  Do you want a program or a C function call to do the encryption?  Are you trying to encrypt a password, or a file with a given password?

As was mentioned in previous respoense to your question, you cannot decrypt passwords.  What you do is encrypt a password, then later, encrypt "test" passwords and see if they match the previously encrypted password - i.e., you never can see the original password in "clear" text - you can only test against the already encrypted one.

Email me at taggart@outdoingit.com if you want to try to clarify things more.

Scott  
0
matth012098Commented:
I dont know how unix crypt works, but you can encrypt a password in many simple ways, I would do use something simple like

Suggestion 1

1. For each letter pick a random number between 1 and 7.
2. Rotate the bits of the character left or right by the random number
3. Store the random number then the character for each character

Then when you want to decrypt the password reverse the bitwise rotation for each character.

Its simple but effective.

Suggestion 2

1. Take the first character and mask the bottom 3 bits.
2. take the value between 0 and 7 and rotate the bits of the next character left/right by that value.

etc.. etc..

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ozoCommented:
#include <crypt.h>
#include <stdio.h>
char s64[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
main(){
  char key[10];
  char salt[3];
  char pass[14];
  srandom(time(0)+getpid());
  salt[0]=s64[random()&63];
  salt[1]=s64[random()&63];
  printf("enter password: ");
  fgets(key,9,stdin);
  strcpy(pass,crypt(key,salt));
  printf("crypt(%s,%s)=%s\n",key,salt,pass);

  while( 1 ){
   printf("enter guess: ");
   fgets(key,9,stdin);
   if( strcmp(pass,crypt(key,pass)) == 0 ){
     printf("Correct\n");
     exit(0);
   }else{
     printf("Wrong\n");
   }
  }
}

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.