Compile a program for hiding user passwords using ASP Technology

Source: Internet
Author: User

Only "legal users" can access queries with permissions on the Internet (or Intranet. This mechanism is implemented through web programs. In the access process, if the program is poorly designed, the user password will be exposed in the address bar (for example: http://www.mmm.nnn/default.asp? Superusername = John & passwd = john123, the username John and password john123 are all exposed.) in this way, the system will not be confidential and secure. How can this problem be avoided? This article uses an ASP (Active Server Pages) program to demonstrate how to hide the user name and password.

ASP is one of Microsoft's latest technologies for processing dynamic network databases. It can be interpreted and published by the Web server iis4.0 (Microsoft Internet Information Server4.0) on Windows NT, use the Active Data Object ADO (ActiveX Data Object) component and access multiple databases (backend) through ODBC (Open Database Connectivity ). The database used in this article is oracle8, and the following ASP program (Name: default. ASP) the function is to query the database. It only takes a part of its hidden user name and password for description.

<% Web_user = request ("web_user") 'Web user name %>

<% Web_user_passwd = request ("web_user_passwd") 'password of the Web user %>

<% 'Encrypts the Web user name and password by adding 32 ASCII codes for each character from left to right to generate a new string, the address line shows the "encrypted" user name and password, instead of the real user name and password, for the purpose of confidentiality. %>

<% Temp1 = "" %>

<% For I = 1 to Len (web_user) %>

<% Temp2 = mid (web_user, I, 1) %>

<% Temp2 = CHR (ASC (temp2) + 32) %>

<% Temp1 = temp1 & temp2 %>

<% Next %>

<% Web_user = temp1 %>

<% Temp1 = "" %>

<% For I = 1 to Len (web_user_passwd) %>

<% Temp2 = mid (web_user_passwd, I, 1) %>

<% Temp2 = CHR (ASC (temp2) + 32) %>

<% Temp1 = temp1 & temp2 %>

<% Next %>

<% Web_user_passwd = temp1 %>

<% 'Establish a connection with the database and define ODBC name (odbcname), Oracle username (orauser), and password (orauser_passwd) %>

<% Set conn = server. Createobject ("ADODB. Connection ")

Conn. Open "odbcname", "orauser", "orauser_passwd"

%>

<% 'Create a query statement-SQL statement %>

<%

Var_ SQL = "select * From verifytab, dw_tab where verifytab. user_pd = '" & web_user_passwd &"'"

Set rs = conn. Execute (var_ SQL) 'matching records are generated in RS. %>

<% 'The user name and password are translated into correct ones, but cannot be displayed in the address bar, which meets the confidentiality requirements. %>

<% Temp1 = "" %>

<% For I = 1 to Len (web_user) %>

<% Temp2 = mid (web_user, I, 1) %>

<% Temp2 = CHR (ASC (temp2)-32) %>

<% Temp1 = temp1 & temp2 %>

<% Next %>

<% Web_user = temp1 %>

<% Temp1 = "" %>

<% For I = 1 to Len (web_user_passwd) %>

<% Temp2 = mid (web_user_passwd, I, 1) %>

<% Temp2 = CHR (ASC (temp2)-32) %>

<% Temp1 = temp1 & temp2 %>

<% Next %>

<% Web_user_passwd = temp1 %>

<% 'Verify the entered webuser name and logging. If yes, go down and no, return to default.htm, which is the default IIS call file %> <> 〈〉

<% If web_user = "superuser" and web_user_passwd = "superuserpd" then

Else

If Rs. EOF then

Response. Redirect ("default.htm ")

End if

End if

%>

<% 'Below is the form Interface Designed with FrontPage 98, with content omitted %>

<HTML>

<Head>

......

You may wish to give it a try. The browser does not have any insecure information and the confidentiality is very good.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.