String trouble

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pjotr Wedersteers

    #1

    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.


  • Virgil Green

    #2
    Re: String trouble

    "Pjotr Wedersteers" <x33159@westert erp.com> wrote in message
    news:41348152$0 $78753$e4fe514c @news.xs4all.nl ...[color=blue]
    > I am using a function that does a very basic encryption (rotation based)[/color]
    of[color=blue]
    > 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 ?[/color]

    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


    Comment

    • Michael Fesser

      #3
      Re: String trouble

      .oO(Ken Robinson)
      [color=blue]
      >Use the function "stripslash es", encrypt(stripsl ashes($_POST['var']))[/color]

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

      Micha

      Comment

      Working...