Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

crypt() function will crypt the given string(passed argument to that function). How can I decrypt that to get the actual string again?

Replies are listed 'Best First'.
Re: decrypt the string
by CountZero (Bishop) on Mar 14, 2009 at 08:28 UTC
    Try all different strings and run them through the crypt() function. The string which gives you the same encrypted result is the one you are looking for.

    Warning: this might take a long time!

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: decrypt the string
by Marshall (Canon) on Mar 14, 2009 at 10:12 UTC
    As others have said, the crypt is a "one way" function. Useful for passwords and such were you just want a yes/no answer of whether the encrypted version of what the user typed is the same as the stuff that is stored on the system (the password isn't stored as plain text).

    If you want a 2-way function, then do a search on Perl Crypt and that will pop up a variety of options, like DES , PGP ( a public key scheme), blowfish, etc. there are a bunch...a whole bunch of options. Which one is best for you depends upon what you are trying to do. The point is that even though, crypt() is not it, there are many Perl modules that can provide this 2-way function.

Re: decrypt the string
by lakshmananindia (Chaplain) on Mar 14, 2009 at 08:11 UTC

    You can't, till now no one found any way to do that

    --Lakshmanan G.

    Your Attempt May Fail, But Never Fail To Make An Attempt

Re: decrypt the string
by MidLifeXis (Monsignor) on Mar 14, 2009 at 19:03 UTC

    crypt() is known as a one-way-hash. You run a function on the data that throws away parts of the data, leaving you with a "fingerprint" of the data. You then compare fingerprints. Not to be confused with a perl hash.

    --MidLifeXis

    The tomes, scrolls etc are dusty because they reside in a dusty old house, not because they're unused. --hangon in this post

Re: decrypt the string
by Anonymous Monk on Mar 14, 2009 at 10:04 UTC
    crypt function doesn't encrypt, so you can't decrypt :)