As other Monks have pointed out, your method is flawed. However you should not be discouraged from experimenting with this idea of yours, just be aware it will make a very _bad_ password system.

What you don't say, most importantly, is how this related to username. Usually we deal with authentication as 2 part, you supply 2 pieces of data and there is some relationship between them discernable with a 'secret' which tells us if the pair is any good.

What you are talking about is really a checksum system. This kind of system embeds 'intrinsic' data within just one datum so that it can be checked for self consistency. This is the basis of ticketing type systems that don't need usernames.
Credit cards have a very basic checksum system that is widely known and trivial to 'crack'. And such is the weakness of using them for login authentication, because once someone has seen more than 2 or 3 examples they can trivially work out the method for generating new and valid ones.
To answer your request for code try doing the following.
#!/usr/bin/perl print STDOUT "Enter a username: "; # ask for a user my $username = <STDIN>; # input the username chomp $username; print STDOUT "Enter a password: "; # ask for a pass my $password = <STDIN>; # input the pass chomp $password; my $crypted = crypt($password.$username,aa); # we store this value fo +r later.... print STDOUT "The username is $username\n"; print STDOUT "The password is $password\n"; print STDOUT "The encrypted passwd is: $crypted\n"; print "\n\n\n"; print STDOUT "Testing out the password system....\n"; while (1) { print STDOUT "Enter the username: "; my $ipusername = <STDIN>; chomp $ipusername; print STDOUT "Enter the password: "; my $ippassword = <STDIN>; chomp $ippassword; my $recrypted = crypt($ippassword.$ipusername,aa); print STDOUT "The retrived passwd is: $recrypted\n"; if ($recrypted eq $crypted) { dologin(); exit 0; } print STDOUT "Login Incorrect, please try again.\n\n\n"; } sub dologin { #do stuff print STDOUT "Login OK, welcome to the system.\n\n\n"; exit 0; }
This uses the standard crypt facility and is _not_ a very good method for passwords, but ok for non critical web services.
BOL
Andy.

In reply to Re: Password Popup help by andyf
in thread Password Popup help by Dirty Luigi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.