469,915 Members | 2,508 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,915 developers. It's quick & easy.

String Gets Truncated: VBScript End of String Character?

Help, I am using an encryption routine that occasionally will encrypt a
string using some extended ASCII characters (ASCII code > 128)

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.

Aug 24 '05 #1
1 4690
Mike wrote:
Help, I am using an encryption routine that occasionally will encrypt
a string using some extended ASCII characters (ASCII code > 128)

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.
Aug 25 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by techno | last post: by
2 posts views Thread by Vance Kessler | last post: by
reply views Thread by Paul Hobbs | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.