473,287 Members | 1,827 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,287 software developers and data experts.

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 4840
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: xyz | last post by:
I have a form that has a text box that allows multi-line text. When I read an 80K file into it, only 64K characters are stored and displayed. However, if I copy from the 80K file using the...
5
by: Bill | last post by:
I need to convert a variable, nNum, into a two-character string. nNum is always less than 100. If nNum is 0, the string needs to be "00", if it's 1, it needs to be "01", if it's 34, it needs to...
7
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using...
0
by: David Bray | last post by:
Has anyone encountered (and solved!) this problem? I have an Access database on a commercial ISP. There is an ASP page/script which creates a recordset from the database and then writes a file...
7
by: techno | last post by:
Dear all, Our bitmap has some x00 values ( '\0' ) and i am storing it in char* array. the problem is that the '\0' is treated as eos character in c and it is truncating it so the characters...
2
by: Vance Kessler | last post by:
We are trying write a new ASP.NET page to work with an existing stateless ASP application. The ASP application creates a cookie and of course stores the cookie values as escaped strings (using the...
12
by: Jack | last post by:
Since, I have not got some desired advise, I am reposting this for some asnwer/valuable suggestion. Thanks. THE FOLLOWING IS A PART OF CODE FROM A ASP PAGE <% sql01 = "SELECT COUNT(*) AS...
0
by: Paul Hobbs | last post by:
Hi, I wanted to create a function which forced a user to enter no more than a specified number of characters. The code for this is below. The idea was simple, if a user is only meant to enter 10...
13
by: Hongyu | last post by:
Hi, I have a datetime char string returned from ctime_r, and it is in the format like ""Wed Jun 30 21:49:08 1993\n\0", which has 26 chars including the last terminate char '\0', and i would...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.