473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

String trouble

I am using a function that does a very basic encryption (rotation based) of
data.
Data is a string which may contain a..z,A..Z,0..9,[],(),|,{}"', length
limited to 255 chars.

The problem I have is the following:

Let's say my $string is 'This is a string'
At a given moment encrypt ($string) yields '6noq4oq4"q6{o]3' as a result.
When I decrypt that I get my original string back. But if I send the
encrypted string in a POST var, this is what I get:
'6noq4oq4\"q6{o]3'; So the " gets escaped and decrypt produces undesired
results.
I don't want that. I want whatever I am putting in to come out verbatim in
the receiving script.

Which function(s) will help me do this ?

THANKS!
Pjotr

PS I am aware of exisiting PHP hash and encrypt functions. This is for
demonstration purposes only.
Jul 17 '05 #1
2 1377
"Pjotr Wedersteers" <x3****@westerterp.com> wrote in message
news:41***********************@news.xs4all.nl...
I am using a function that does a very basic encryption (rotation based) of data.
Data is a string which may contain a..z,A..Z,0..9,[],(),|,{}"', length
limited to 255 chars.

The problem I have is the following:

Let's say my $string is 'This is a string'
At a given moment encrypt ($string) yields '6noq4oq4"q6{o]3' as a result.
When I decrypt that I get my original string back. But if I send the
encrypted string in a POST var, this is what I get:
'6noq4oq4\"q6{o]3'; So the " gets escaped and decrypt produces undesired
results.
I don't want that. I want whatever I am putting in to come out verbatim in
the receiving script.

Which function(s) will help me do this ?


What Ken said (stripslashes()), but you should also be aware that the slash
got there in the first place because you probably have magic_quotes enabled
for your PHP installation. It is escaping the quotes for you.

- Virgil
Jul 17 '05 #2
.oO(Ken Robinson)
Use the function "stripslashes", encrypt(stripslashes($_POST['var']))


Use get_magic_quotes_gpc() first to check if magic quotes are enabled
(they are by default, but you shouldn't rely on that).

Micha
Jul 17 '05 #3

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

Similar topics

108
by: Bryan Olson | last post by:
The Python slice type has one method 'indices', and reportedly: This method takes a single integer argument /length/ and computes information about the extended slice that the slice object would...
6
by: Mark | last post by:
Hi, My page has a table with many columns such that the right-side of the table gets chopped off when printed. I specify a table width of 100%, but otherwise no cell dimensions are specified. ...
1
by: Hai Ly Hoang | last post by:
Hi, I have string which contains linefeed and carry-return characters (eg. "Banana \r\n Apple \r\n..."); To print this string, i make use of PrintPage event of PrintDocument with DrawString...
9
by: Fei Liu | last post by:
In Accellerated C++, the author recommends that in a header file one should not declare using std::string, using std::vector etc instead one should directly specify the namespace specifier in...
3
by: Wyz | last post by:
Hello. I have troubles giving me a big headache, I hope somebody may help me. I'm using Indy.Sockets to have FTP support for my VB.NET application (I also tried with another dll made in C# but the...
14
by: Josh Baltzell | last post by:
I am having a lot more trouble with this than I thought I would. Here is what I want to do in pseudocode. Open c:\some.pdf Replace "Replace this" with "Replaced!" Save c:\some_edited.pdf I...
19
by: VK | last post by:
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/ b495b4898808fde0> is more than one month old - this may pose problem for posting over some news servers. This is why I'm...
2
by: jenniamia | last post by:
I need to make the string "myFile" into a byte and then put it in the database as a file/image, where later it needs to be pulled out and back into a string from the byte. I'm really having trouble...
3
blackstormdragon
by: blackstormdragon | last post by:
My trouble causing lines are maked within the code. #include<iostream> #include<string> using namespace std; void main() { string* head; string* tail;
21
by: yogicoder | last post by:
following is the code to accept a string from user, but i get segmentation fault as soon i have finished entering the string i.e. as soon as i press the 'enter' key. #include <stdio.h>...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
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...
0
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,...
0
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...

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.