Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > String Gets Truncated: VBScript End of String Character?

Reply
Thread Tools

String Gets Truncated: VBScript End of String Character?

 
 
Mike
Guest
Posts: n/a
 
      08-24-2005
Help, I am using an encryption routine that occasionally will encrypt a
string using some extended ASCII characters (ASCII code > 12

I am wondering if there is a reserved character in VB that signifies
the end of a string of characters.

Here is what happens: I am encrypting certain fields before adding
them to a SQL string. On occassion, the SQL string will simply end in
the middle of the encrypted value.

Example code

sSQL = "EXEC SaveDetails " & _
" @iDetailID = " & iDetailID & ", " & _
" @sEncryptedText = '" & _
replace(EncryptText(sText),"'","''") & "', " & _
" @iOtherValue = 6"

Normally Response.Write would print something like this:

using Response.Write(Server.HTMLEncode(sSQL)):

EXEC SaveDetails @iDetailID = 3, @sEncryptedText = 'aw@##@QASV@#AV (!',
@iOtherValue = 6

Occasionally on certain inputs for sEncryptedText it will print:

EXEC SaveDetails @iDetailID = 3, @sEncryptedText = '@#DFVIDXZI

Is my encryption algorithm possible generating a reserved character
that signifies the end of a string? Does such a character exist in
VBscript? Any help would be appreciated.

FYI, I'd rather not post my encryption routine. Please let me know if
you feel it would be necessary.

 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      08-25-2005
Mike wrote:
> Help, I am using an encryption routine that occasionally will encrypt
> a string using some extended ASCII characters (ASCII code > 12
>
> I am wondering if there is a reserved character in VB that signifies
> the end of a string of characters.
>
> Here is what happens: I am encrypting certain fields before adding
> them to a SQL string. On occassion, the SQL string will simply end in
> the middle of the encrypted value.
>
> Example code
>
> sSQL = "EXEC SaveDetails " & _
> " @iDetailID = " & iDetailID & ", " & _
> " @sEncryptedText = '" & _
> replace(EncryptText(sText),"'","''") & "', " & _
> " @iOtherValue = 6"
>
> Normally Response.Write would print something like this:
>
> using Response.Write(Server.HTMLEncode(sSQL)):
>
> EXEC SaveDetails @iDetailID = 3, @sEncryptedText = 'aw@##@QASV@#AV
> (!', @iOtherValue = 6
>
> Occasionally on certain inputs for sEncryptedText it will print:
>
> EXEC SaveDetails @iDetailID = 3, @sEncryptedText = '@#DFVIDXZI
>
> Is my encryption algorithm possible generating a reserved character
> that signifies the end of a string? Does such a character exist in
> VBscript? Any help would be appreciated.
>
> FYI, I'd rather not post my encryption routine. Please let me know if
> you feel it would be necessary.


Try using parameters (in this example "conn" is a previously opened
connection object):

conn.SaveDetails iDetailID, EncryptText(sText), 6

The bonus (if this solves your problem) is that using parameters saves you
the extra step of escaping your embedded apostrophes - less processing
needed.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Return of gets gets John Joyce Ruby 0 04-23-2007 01:38 PM
gets gets John Joyce Ruby 2 03-26-2007 04:00 PM
XMLHttpRequest gets data to display in element but data gets appended not replaces previous! libsfan01 Javascript 5 12-20-2006 06:25 AM
Not only the selected HREF gets surrounded, but the whole row gets surrounded Stefan Mueller HTML 5 07-10-2006 11:53 AM
Microsoft VBScript compilation error '800a03f6' Expected 'End' ?, Line 0 Adam Short ASP General 3 04-21-2005 12:56 PM



Advertisments