Re: [PHP] can I compile php source

2004-12-21 Thread Darren Wheatley
I can't believe you can spend so much energy on this flame/agrovated
response crap when a small amount of that energy would have simply answered
this guys question.

No wonder there is so much war. Mostly started by people who know how to be
self sufficient. Don't worry. In 100 years we will all be dead, maybe the
next generation will actually learn something John.

Darren

Bruce Douglas [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 and this response was helpful to the guy who asked the original question,
how

 i mean, aside from showing that you know how to do a link, what did you
show

 peace...



 -Original Message-
 From: John Nichel [EMAIL PROTECTED]
 Sent: Dec 20, 2004 4:32 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] can I compile php source

 QT wrote:
  hi,
 
  is there any way to compile php source to make binary file for
protecting
  source code?
 
  best regards
 

 Yes.

 http://www.catb.org/~esr/faqs/smart-questions.html

 --
 By-Tor.com
 ...it's all about the Rush
 http://www.by-tor.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Encryption

2004-12-21 Thread Darren Wheatley
Richard,

Thanks for your help.

The code (as I mentioned) was not mine. I did however find the example from
the link you sent me to and followed that. It works quite well.

Again, thanks for your time.

Darren


Richard Lynch [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
  I have found some code and set up a test bed for it, but it fails to
  return
  the same value after the 26th item. I was hoping someone could take a
  look
  and maybe tell me why? There is very little help out there for
  encryption.
  If you know of a working example/tutorial, can you please reply with a
  link?
 
  Many thanks,
 
  Darren
 
  ?
  global $arrAlphaVals;
  global $intTot;

 'global' makes NO SENSE outside the context of a function body.
 Get rid of these.

  $intTot = 5000;
  $arrAlphaVals = array();
 
  function init()
  {
  global $arrAlphaVals;
  global $intTot;
  for ($i=0;$i$intTot;$i++)
  {
  $arrAlphaVals[$i] = sprintf(%016s,
  strtoupper(dechex($i)));
  }
  return $arrAlphaVals;
  }
  function main()
  {
  global $arrAlphaVals;
  global $intTot;
  init();
 
  $arrError = array();
  echo Encryption testbr\n;
  for ($i=0;$i$intTot;$i++)
  {
  if ($i%1000 == 0)
  {
  echo $i.br;
  flush();
  }
  $strInit = $arrAlphaVals[$i];
  $strEncVal = encryptIt($strInit);
  $strOut = decryptIt($strEncVal);
  //echo In: .$strInit., Enc: .$strEncVal., Out: .$strOut.br;
  if ($strOut != $strInit)
  {
  $strError .= Failed on: .$i.br\n;
  $arrError[$strInit] = $strOut;
  }
  }
  if (sizeof($arrError)  0)
  {
  // There were errors
  foreach ($arrError as $strKey = $strVal)
  {
  echo Input: '.$strKey.' failed with result
  '.$strVal.'br\n;
  }
  echo hr.$strError;
  }
  echo hrTested .$i. cases. Done.br\n;
  }
  function encryptIt($strIn)
  {
  $key = biteme;
  $strRet = _mencrypt($strIn, $key);
  return $strRet;
  }
  function decryptIt($strIn)
  {
  $key = biteme;
  $strRet = _mdecrypt($strIn, $key);
  return $strRet;
  }
  function _mencrypt($input,$key)
  {
  $input = str_replace(\n,,$input);
  $input = str_replace(\t,,$input);
  $input = str_replace(\r,,$input);
  $key = substr(md5($key),0,24);
  $td = mcrypt_module_open ('tripledes', '', 'ecb', '');
  $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td),
  MCRYPT_RAND);

 Where did you call srand() as the manual says you should?
 http://php.net/mcrypt_create_iv

  mcrypt_generic_init ($td, $key, $iv);

 Why are you not checking your error codes here?
 This function alone has -3, -4, and unknown error codes you should be
 checking.

 *EVERY* function with a documented error code return mechanism needs you
 to write code to *CHECK* that return code.

 You'll find a *TON* of things out a lot faster if you write that extra few
 lines of code for each function call.

  $encrypted_data = mcrypt_generic ($td, $input);
  mcrypt_generic_deinit ($td);
  mcrypt_module_close ($td);
  return trim(chop(base64_encode($encrypted_data)));
  }
 
  //$input - stuff to decrypt
  //$key - the secret key to use
 
  function _mdecrypt($input,$key)
  {
  $input = str_replace(\n,,$input);
  $input = str_replace(\t,,$input);
  $input = str_replace(\r,,$input);
  $input = trim(chop(base64_decode($input)));
  $td = mcrypt_module_open ('tripledes', '', 'ecb', '');
  $key = substr(md5($key),0,24);
  $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td),
  MCRYPT_RAND);
  mcrypt_generic_init ($td, $key, $iv);
  $decrypted_data = mdecrypt_generic ($td, $input);
  mcrypt_generic_deinit ($td);
  mcrypt_module_close ($td);
  return trim(chop($decrypted_data));
  }
  main();
  ?
 
  The original encryption and decryption code came from Jeremy Stansfield
  (http://www.weberdev.com/get_example-3752.html)


 --
 Like Music?
 http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Encryption

2004-12-20 Thread Darren Wheatley
Hey all.

I am trying to get encryption working for my site.

I have found some code and set up a test bed for it, but it fails to return
the same value after the 26th item. I was hoping someone could take a look
and maybe tell me why? There is very little help out there for encryption.
If you know of a working example/tutorial, can you please reply with a link?

Many thanks,

Darren

?
global $arrAlphaVals;
global $intTot;

$intTot = 5000;
$arrAlphaVals = array();

function init()
{
global $arrAlphaVals;
global $intTot;
for ($i=0;$i$intTot;$i++)
{
$arrAlphaVals[$i] = sprintf(%016s, strtoupper(dechex($i)));
}
return $arrAlphaVals;
}
function main()
{
global $arrAlphaVals;
global $intTot;
init();

$arrError = array();
echo Encryption testbr\n;
for ($i=0;$i$intTot;$i++)
{
if ($i%1000 == 0)
{
echo $i.br;
flush();
}
$strInit = $arrAlphaVals[$i];
$strEncVal = encryptIt($strInit);
$strOut = decryptIt($strEncVal);
//echo In: .$strInit., Enc: .$strEncVal., Out: .$strOut.br;
if ($strOut != $strInit)
{
$strError .= Failed on: .$i.br\n;
$arrError[$strInit] = $strOut;
}
}
if (sizeof($arrError)  0)
{
// There were errors
foreach ($arrError as $strKey = $strVal)
{
echo Input: '.$strKey.' failed with result
'.$strVal.'br\n;
}
echo hr.$strError;
}
echo hrTested .$i. cases. Done.br\n;
}
function encryptIt($strIn)
{
$key = biteme;
$strRet = _mencrypt($strIn, $key);
return $strRet;
}
function decryptIt($strIn)
{
$key = biteme;
$strRet = _mdecrypt($strIn, $key);
return $strRet;
}
function _mencrypt($input,$key)
{
$input = str_replace(\n,,$input);
$input = str_replace(\t,,$input);
$input = str_replace(\r,,$input);
$key = substr(md5($key),0,24);
$td = mcrypt_module_open ('tripledes', '', 'ecb', '');
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);
mcrypt_generic_init ($td, $key, $iv);
$encrypted_data = mcrypt_generic ($td, $input);
mcrypt_generic_deinit ($td);
mcrypt_module_close ($td);
return trim(chop(base64_encode($encrypted_data)));
}

//$input - stuff to decrypt
//$key - the secret key to use

function _mdecrypt($input,$key)
{
$input = str_replace(\n,,$input);
$input = str_replace(\t,,$input);
$input = str_replace(\r,,$input);
$input = trim(chop(base64_decode($input)));
$td = mcrypt_module_open ('tripledes', '', 'ecb', '');
$key = substr(md5($key),0,24);
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);
mcrypt_generic_init ($td, $key, $iv);
$decrypted_data = mdecrypt_generic ($td, $input);
mcrypt_generic_deinit ($td);
mcrypt_module_close ($td);
return trim(chop($decrypted_data));
}
main();
?

The original encryption and decryption code came from Jeremy Stansfield
(http://www.weberdev.com/get_example-3752.html)

Thanks again!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Encryption

2004-12-20 Thread Darren Wheatley
If nobody has a better suggestion I am simply going to do a reverse check
and for those that fail implement a massive hack. I really don't want to do
that...

Please, if you have any ideas give me a yell?

D

Darren Wheatley [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hey all.

 I am trying to get encryption working for my site.

 I have found some code and set up a test bed for it, but it fails to
return
 the same value after the 26th item. I was hoping someone could take a look
 and maybe tell me why? There is very little help out there for encryption.
 If you know of a working example/tutorial, can you please reply with a
link?

 Many thanks,

 Darren

 ?
 global $arrAlphaVals;
 global $intTot;

 $intTot = 5000;
 $arrAlphaVals = array();

 function init()
 {
 global $arrAlphaVals;
 global $intTot;
 for ($i=0;$i$intTot;$i++)
 {
 $arrAlphaVals[$i] = sprintf(%016s, strtoupper(dechex($i)));
 }
 return $arrAlphaVals;
 }
 function main()
 {
 global $arrAlphaVals;
 global $intTot;
 init();

 $arrError = array();
 echo Encryption testbr\n;
 for ($i=0;$i$intTot;$i++)
 {
 if ($i%1000 == 0)
 {
 echo $i.br;
 flush();
 }
 $strInit = $arrAlphaVals[$i];
 $strEncVal = encryptIt($strInit);
 $strOut = decryptIt($strEncVal);
 //echo In: .$strInit., Enc: .$strEncVal., Out: .$strOut.br;
 if ($strOut != $strInit)
 {
 $strError .= Failed on: .$i.br\n;
 $arrError[$strInit] = $strOut;
 }
 }
 if (sizeof($arrError)  0)
 {
 // There were errors
 foreach ($arrError as $strKey = $strVal)
 {
 echo Input: '.$strKey.' failed with result
 '.$strVal.'br\n;
 }
 echo hr.$strError;
 }
 echo hrTested .$i. cases. Done.br\n;
 }
 function encryptIt($strIn)
 {
 $key = biteme;
 $strRet = _mencrypt($strIn, $key);
 return $strRet;
 }
 function decryptIt($strIn)
 {
 $key = biteme;
 $strRet = _mdecrypt($strIn, $key);
 return $strRet;
 }
 function _mencrypt($input,$key)
 {
 $input = str_replace(\n,,$input);
 $input = str_replace(\t,,$input);
 $input = str_replace(\r,,$input);
 $key = substr(md5($key),0,24);
 $td = mcrypt_module_open ('tripledes', '', 'ecb', '');
 $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td),
MCRYPT_RAND);
 mcrypt_generic_init ($td, $key, $iv);
 $encrypted_data = mcrypt_generic ($td, $input);
 mcrypt_generic_deinit ($td);
 mcrypt_module_close ($td);
 return trim(chop(base64_encode($encrypted_data)));
 }

 //$input - stuff to decrypt
 //$key - the secret key to use

 function _mdecrypt($input,$key)
 {
 $input = str_replace(\n,,$input);
 $input = str_replace(\t,,$input);
 $input = str_replace(\r,,$input);
 $input = trim(chop(base64_decode($input)));
 $td = mcrypt_module_open ('tripledes', '', 'ecb', '');
 $key = substr(md5($key),0,24);
 $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td),
MCRYPT_RAND);
 mcrypt_generic_init ($td, $key, $iv);
 $decrypted_data = mdecrypt_generic ($td, $input);
 mcrypt_generic_deinit ($td);
 mcrypt_module_close ($td);
 return trim(chop($decrypted_data));
 }
 main();
 ?

 The original encryption and decryption code came from Jeremy Stansfield
 (http://www.weberdev.com/get_example-3752.html)

 Thanks again!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php