473,837 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Baffling Problems With Class

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_URAN DOM )
{
$this->algorithm = $algorithm ;
$this->mode = $mode ;
$this->random_sourc e = $random_source ;
}

public function generate_iv()
{
$this->iv = mcrypt_create_i v( mcrypt_get_iv_s ize( $this->algorithm, $this->mode ) , $this->random_sourc e ) ;
}

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 ) ;
}

}

?>

Jan 5 '06 #1
2 1368
This will work in php 5, but for php 4 change

private $algorithm ;
private $mode ;
etc...

To

var $algorithm ;
var $mode ;
etc...

Jan 5 '06 #2
Sean wrote:
This will work in php 5, but for php 4 change

private $algorithm ;
private $mode ;
etc...

To

var $algorithm ;
var $mode ;
etc...

That fixed it!!!

Thanks!!

You da man!

:-)

Jan 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4599
by: TimS | last post by:
I am getting a baffling File not found error (0x800A0035). I am writing asp on a windows 2000 server. I build a path and filename from several fields in a jet database using SQL commands, like this: Sql = "SELECT dirs.rootname,dirs.dirname FROM dirs" RS.open Sql RS.movefirst do while not RS.EOF temp1=trim(RS("rootname"))
2
1385
by: Chris Fonnesbeck | last post by:
I thought I knew how to do error handling in python, but apparently I dont. I have a bunch of code to calculate statistical likelihoods, and use error handling to catch invalid parameters. For example, for the bernoulli distribution, I have: def bernoulli_like(self, x, p, name='bernoulli'): """Bernoulli log-likelihood""" # Ensure proper dimensionality of parameters dim = shape(x)
2
1820
by: bfrasca | last post by:
I have a well-formed XML file that I am trying to load into a dataset using the ReadXML method. It keeps telling me that "there are multiple root elements". I can view the data using XML Designer in Visual Studio 2003 without any problems and the schema and file have been validated using several different tools. I even successfully generated a typed dataset with Visual Studio 2003 by importing the XML into my project. I'm baffled, does...
12
1519
by: Mike | last post by:
I have posted this before, but no one responds, so here it goes again. I think my question is intimidating people and I have no idea why?!? This is not a new concept. You can do this with other programming languages, so why is C# so different? Again, here is my baffling C# question. I have C# code that opens an application, but right after it opens I am confronted by prompts for information (i.e. "Please enter your id"). I would like to...
4
1534
by: Steve | last post by:
I'm currently running into a problem, and I have no idea what to make of it. I have a class with nested clases and static properties that I'm using to store configuration information using a custom configuration section. When my code accesses one of the static properties the static constructors are fired, and the code goes in and pulls the data from the configuration section. In the current instance, I'm getting a connection string....
5
1253
by: DarkBlue | last post by:
Following is a code snippet from a pythoncard app the problem is with the sql string called iq1 If either mysubject or mytalktext contains an apostrophe the update fails : Example: mysubject="Let's Eat" this fails mysubject="Lets Eat" this works fine What options do I have to avoid this issue but still can use apostrophes in my input data ?
2
2539
by: noddy | last post by:
In both IE7 and FF2(using firebug) I get the same error. I have a page that displays work contacts' details within a <DIV class = "contactBase" >. The div has a header area <div id="contactHeader" class="client" > in which is displayed the contact's name. Within this header area div I also want to display in smaller font
3
1685
by: Scotty | last post by:
I'm a C++ novice and need help figuring out some odd behavior I've encountered. Here's the situation: I create a class and have its constructor store a random number in a private "number" variable. The class also has a "getNumber()" function that returns its stored number. A function in the program creates five objects of this class and five pointers to these objects, the latter of which are stored in a global array. When "getNumber()"...
1
1293
by: Tim Redfern | last post by:
Hi I'm having an issue that is probably obvious to somebody here but its baffling me.. I'm using python (2.5.1) on an embedded linux sytem system (kernel 2.6.19 I think) with only 32MB memory (for an art project). My python code runs nicely when launched manually from a login shell, ps shows its using 11MB or so of memory. However, when I try to launch the same code from a startup script, it
0
9685
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10886
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10580
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10277
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7007
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5853
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4479
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4052
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3126
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.