Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts

    Encryption Strangeness

    OK, so the problem wasnt what I thought it was but this is the function
    Code:
    Function CheckString (s, endchar)
    s=replace(s, "'", "''")
    	CheckString="'" & s & "'" & endchar
    End Function
    which should escape all single quotes and then wrap quotes around the whole string ready for insertion in an sql statement.
    however I'm having a problem when I insert a blowfish encrypted string into the function, it puts the first quote on the beginning but not at the end (but only sometimes)
    Last edited by NancyJ; 08-25-2005 at 12:48 PM.

  • #2
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    what is endchar for?

    this is gunna sound stupid but are you sure you arent adding ' to the end and then adding endchar after it so its no longer on the end?

    you may also wish to note that if you do not want to alter the value of global s (if there is a global s) you can simply use
    Code:
    Function CheckString(s, endchar)
    	CheckString = "'" & Replace(s, "'", "''") & "'" & endchar
    End Function
    for example if you were using s = CheckString(s, ".") this might mess up a bit

  • #3
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    end char is usually a comma the function prepares the string for insertion into a mysql database, so sometimes its a comma sometimes its blank.
    In the end I had to use base64 instead of blowfish. I spoke to my boss and he said they never solved the issue when they used it on another site - which would probably explain why I couldnt fix it.
    Basically sometimes the encryption would throw out a character that bombed out the sql statement because it would destroy anything on the same line as it, so you would only get half the line and then the code would carry on.

    I tried doing a while loop so that the encryption would run again if it had gone funcky but in the code it always came back as having the ', on the end but if you tried to display it or insert it into an aql statement it crapped out.

  • #4
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    i have had a problem similar to that kinda before, it just happened when i tried to write binary data that had been adodb.streamed into txt eg when you try and write a charcacter that has an ascii index of less than 32 (eg the backspace character) but this did not matter until i tried to write it out, when it was in the string it was fine but when i tried to write it out it just stopped dead in its tracks and moved on to the next line, maby it just confuses the interpreter


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •