Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I settled on:

use Crypt::SaltedHash; # Individual registers as a new user, supplying a username # and a password/passphrase in a form on a web page. # But, for illustration: my $desired_password = 'Owning 2 boats is 1 boat too many!'; my $csh = Crypt::SaltedHash->new(algorithm => 'SHA-256'); $csh->add($desired_password); my $digest = $csh->generate; # Some might prefer to call 'digest' # something like 'hash_string' instead # Then the value of $digest is stored to a file or database # along with the corresponding username (not shown). # # By the way, for the $desired_password shown, the digest that # was generated is this string: # # {SSHA256}rn8PJZd//2EsEgHTBQ0izsN2T7AJMsLRH19oLIA5unaf8OaJ # # ...but it would be very different for you, because Crypt::SaltedHash # randomizes the "salt" used in the creation of the digest. And it # would be very different for me, if this script were to be run a # second time, even though it would be processing the same 'Owning 2 # boats is 1 boat too many!' desired password.

In another program, when the individual enters a username and a password/passphrase into a login form:

use Crypt::SaltedHash; my $asserted_password = ___; # Some process to retrieve the value # entered on a web form by the user, not illustrated here my $digest = ___; # Some retrieval process that looks up the earlier-s +tored # digest corresponding to the username, not illustrated here my $is_valid = Crypt::SaltedHash->validate( $digest, $asserted_passwor +d ); grant_account_access() if ( $is_valid );

In reply to Re: Replacing crypt() for password login via a digest - looking for stronger alternative by davebaker
in thread Replacing crypt() for password login via a digest - looking for stronger alternative by davebaker

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (None)
    As of 2021-10-17 03:29 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My first memorable Perl project was:







      Results (71 votes). Check out past polls.

      Notices?