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 ) ;
}
}
?> 2 1367
This will work in php 5, but for php 4 change
private $algorithm ;
private $mode ;
etc...
To
var $algorithm ;
var $mode ;
etc...
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!
:-) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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"))
|
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)
|
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...
|
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...
|
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....
| |
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 ?
|
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
|
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()"...
|
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
|
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,...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |