Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl to Cold Fusion, password encrypt

Status
Not open for further replies.

pixiesfb

Programmer
Apr 27, 2001
62
US
So we're rewriting a Perl application in Cold Fusion, problem is I don't know Perl, but can follow the logic well enough to get by. I have hit a roadblock though. Perl encrypts the password with the following code:

$alphabet = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
substr($salt, 0, 1) = substr($alphabet, rand(63), 1);
substr($salt, 1, 1) = substr($alphabet, rand(63), 1);
$password = substr($ssn,3,6);
$enc_password = crypt($password, $salt);
$password = $enc_password;

Is there any way to duplicate this in Cold Fusion?
If not, any bright ideas?
 
You can use the Hash function to encrypt the password. I believe it uses a Mod 5 algorithm. I'm not sure how you're using it, but the syntax would be:

hash(password)

So, you could say:

<cfset EncryptedPassword = hash(password)>

Hope This Helps!

Ecobb

&quot;Alright Brain, you don't like me, and I don't like you. But lets just do this, and I can get back to killing you with beer.&quot; - Homer Simpson
 
Hmm,

Yes, that will encrypt the password. But I need to encrypt in the same way that Perl did, so it can be decrypted with the same algorithm.
 
I think it's going to be tough getting ColdFusion to decode a password that was encoded by PERL, if that's what you mean. ColdFusion and PERL don't speak the same encryption, unfortunately. Short of writing your own parsers to match PERL's encryption algorhythm (which, I don't believe has been published), you're going to be out-of-luck, I believe.

Now... you certainly can replicate the style of encryption... like:
Code:
<CFSCRIPT>
sAlphabet = &quot;./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&quot;;

sSalt = &quot;#Mid(sAlphabet,randRange(1,Len(sAlphabet)),1)##Mid(sAlphabet,randRange(1,Len(sAlphabet)),1)#&quot;;

password = Mid(ssn,4,7);
enc_password = Encrypt(password,sSalt);
password = enc_password;
</CFSCRIPT>
but I'm sure that's not what you're after, since it returns a different result than PERL would.


HOWEVER... depending on your environment and how your PERL script was written, you might be able to call it from within your ColdFusion page
Code:
   <CFEXECUTE name=&quot;/webroot/cgi-bin/encrypter.pl&quot;
              arguments=&quot;#ssn#&quot;
              variable=&quot;encryptedPassword&quot;></cfexecute>
or, if you're lucky to have a PERL binary executable (usually under Windows), you call that EXE with your PERL script as an argument.



-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top