If you are needing to store some sort of a token to access a remote environment, the script will need to have some way to reverse any obfuscation that you apply to it in order to hide it. If you hash(1) a password and put the hash in your program, either the remote system needs to accept the hash (which is now acting as the password), or your program needs to be able to reverse the transformation that you have used. If the user can read the script, they can read the transformation code.

There are other solutions for this -- most that I know of use some other form of protection (based on file system permissions for the actual data - such as ssh keys, plaintext stored password in a protected file; based on a trusted source handing out authentication tokens - kerberos, a protected local process that hands out tokens to a requesting process once it has been validated; or others). This is an interesting problem space with many solutions, some less bad than others.

1 - Usually when you refer to a hashed password, the mechanism used to convert from plaintext to the hash is lossy - it throws away information when generating the hash. This makes the function one-way, unless some dictionary attach or weakness in the hashing algorithm is known. If implemented correctly, you should not be able to go back from the hash to the original text, you should just be able to compare that the hash function supplied to a given plaintext matches the stored hash.

--MidLifeXis


In reply to Re: Perl hash password on existing password by MidLifeXis
in thread Perl hash password on existing password by MartinTomcik

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.