SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Threaded View

  1. #1
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to convert PERL to PHP, or run PERL from PHP?

    I have a snippet of working PERL code from my web host that I need to execute from PHP. Is there any way to call a perl program from a PHP page, or somehow "translate" it into PHP?

    Unfortunately, the encryption method used must stay exactly the same. This code is already in production, so it would be an incredible burden to use a different method.

    Code:
    $newpassword = "text";
    $encrypted_password = mycrypt($new_password});
    
    sub mycrypt {
    	my($pw)=@_;
    	$pw = crypt $pw,gen_salt(2);
    	return $pw;
    	}
    
    sub gen_salt {
    	my($size)=@_;
    	my($s,$len,$passwd,$c,$i);
    	$s = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    	$len = length($s);
    	$passwd = "";
    	for($i=0;$i<$size;$i++) {
    		$c = int(rand $len)+1;
    		$passwd .= substr($s,$c,1);
    		}
    	return $passwd;
    	}
    Last edited by hstraf; Mar 19, 2001 at 17:03.
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •