Reply to Baffling Problems With Class

Your name:

Reply:


Posted by Double Echo on 10/11/74 11:36

Hi,

Forgive me if I ask a dumb question, I'm new to classes and object programming with PHP,
and cannot figure out what the problem is with this class. Maybe I have overlooked
something but just can't see it. The error message usually means a typo or something
that I missed.

I get this error:

Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in crypt_class.php on line 6

I cannot figure it out. I took this class from the book Essential PHP Security, and
hand-coded it line for line. But it is baffling why it errors out. I did modify
the constructor to have the same name as the class, in the book they use __construct
instead of the class name, but it didn't seem to matter or didn't appear to be the
problem.

I have tried to use this on two different machines, same error on each machine.
One machine has 4.3.11 the other 4.4.1, but both produce the same error.

Thanks in advance!!

( I can't post my email my employer will fire me )

<?php

class crypt
{

private $algorithm ;
private $mode ;
private $random_source ;

public $crypt_key ;

public $cleartext ;
public $ciphertext ;
public $iv ;

public function crypt( $algorithm = MCRYPT_BLOWFISH, $mode = MCRYPT_MODE_CBC, $random_source = MCRYPT_DEV_URANDOM )
{
$this->algorithm = $algorithm ;
$this->mode = $mode ;
$this->random_source = $random_source ;
}

public function generate_iv()
{
$this->iv = mcrypt_create_iv( mcrypt_get_iv_size( $this->algorithm, $this->mode ) , $this->random_source ) ;
}

public function encrypt()
{
$crypt_key = "mykey" ;
$this->ciphertext = mcrypt_encrypt( $this->algorithm, $crypt_key, $this->cleartext, $this->mode, $this->iv ) ;
}

public function decrypt()
{
$crypt_key = "mykey" ;
$this->cleartext = mcrypt_decrypt( $this->algorithm, $crypt_key, $this->ciphertext, $this->mode, $this->iv ) ;
}

}

?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация