Jonathan Smith
Jonathan Smith

Reputation: 2599

Encoding / encryption in Classic ASP

I have two web pages, /default.asp and /mobile/default.asp.

Both pages have the following declaration:

meta http-equiv="Content-Type" content="text/html;charset=utf-8"

In addition, both pages use the same include file which provides access to some string encryption and decryption functions.

THe problem i am experiencing is that two pages using the same charset encoding and the same encryption function are giving two different strings when the same string is encrypted with the same key.

Any ideas? The incorrect output contains lots of black diamonds with question marks in them. In HEX, these appear as FD FF.

ADDITIONAL - The encrypted data is getting stored in a SQL database and this is how i am seeing the two different encryption results.

So, its the same encryption function with the output being in the same SQL database but from two different asp pages (but they are using the same charset).

Upvotes: 0

Views: 910

Answers (2)

Jonathan Smith
Jonathan Smith

Reputation: 2599

After about 8 hours of trial and error, i managed to find the problem.

THe ASP page itself was created and saved as UTF-8 encoded and it needed to be UTF-8 without BOM

Upvotes: 0

AardVark71
AardVark71

Reputation: 4126

you can set your server-side codepage as follows to UTF-8 :

<%@ Language="VBSCRIPT" CODEPAGE="65001"%>

or

<% 
Response.CodePage = "utf-8"
%>

It is common to keep your output the same as your codepage. The output is what you are setting with the meta tag and could also be set as follows:

<% 
Response.Charset = "utf-8"
%>

Upvotes: 1

Related Questions