使用MD5编码实现数据库用户密码字段的加密
1 前言 众所周知,MD5是目前应用最多的密码保护方法,该编码传说为不可逆加密编码<也就是说,永运无法倒算原码>。 使用MD5加密用户的操作密码,可以有效防止系统维护人员直接进入数据库时出现系统安全漏洞<直接使用SELECT语句查询,将用户密码字段只能看
1 前言
众所周知,MD5是目前应用最多的密码保护方法,该编码传说为不可逆加密编码<也就是说,永运无法倒算原码>。 使用MD5加密用户的操作密码,可以有效防止系统维护人员直接进入数据库时出现系统安全漏洞<直接使用SELECT语句查询,将用户密码字段只能看到乱码,或者"****">
本文针对密码字段加密,作一实例,希望能给大家系统建设过程带来帮助。
2 技术点
2.1 DBMS_OBFUSCATION_TOOLKIT.MD5
DBMS_OBFUSCATION_TOOLKIT.MD5是MD5编码的数据包函数,但偶在使用select DBMS_OBFUSCATION_TOOLKIT.MD5(input_string =>'abc') a from Dual时,却有错误提示,看来该函数只能直接在程序包中调用,不能直接应用于SELECT语句。
2.2 Utl_Raw.Cast_To_Raw
DBMS_OBFUSCATION_TOOLKIT.MD5返回的字串,是RAW类型,要正确显示,需要经过Utl_Raw.Cast_To_Raw转换<该知识点则之前论坛中NICK511贴子中获得>
3 实例演练 3.1 测试环境 使用Scott/Tiger@YourDBName --3.2.1 创建数据表 Drop Table Test_User; CREATE TABLE Test_User ( UserName VARCHAR2(30) NOT NULL, PassWord VARCHAR2(2000) NOT NULL ) / --3.2.2 创建程序包 Create Or Replace Package Test_MD5 AS Function FN_GetMD5(P_Str In VarChar2) Return VarChar2; Function FN_CheckUser (P_UserName In VarChar2 ,P_Password In VarChar2) Return Number; End; / CREATE OR REPLACE PACKAGE BODY Test_MD5 AS FUNCTION FN_GetMD5 (P_Str IN VARCHAR2) RETURN VARCHAR2 AS BEGIN RETURN DBMS_OBFUSCATION_TOOLKIT.MD5( input_string => Upper(P_Str)); END; Function FN_CheckUser (P_UserName IN VARCHAR2 ,P_Password IN VARCHAR2) Return Number Is L_Password VarChar2(2000); BEGIN SELECT Utl_Raw.Cast_To_Raw(Password) INTO L_Password FROM Test_User WHERE Upper(UserName) = UPPER(P_UserName); If Utl_Raw.Cast_To_Raw(FN_GetMD5(P_Password))=L_Password Then Return 1; Else Return 0; End If; EXCEPTION WHEN NO_DATA_FOUND THEN Return 0; END; End; / --3.3 测试 Delete Test_User; Insert Into Test_User Values('A',Test_MD5.FN_GetMD5('aa')); Insert Into Test_User Values('B',Test_MD5.FN_GetMD5('bb')); Commit; Select Test_MD5.FN_CheckUser('a','aa') From Dual; Select Test_MD5.FN_CheckUser('a','bb') From Dual; 注:对MD5编码的比较,可以不需要经过Utl_Raw.Cast_To_Raw转换。此处使用Utl_Raw.Cast_To_Raw的目的,是为了调试方便,同时多提供一个知识点。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In the Windows 10 system, the password policy is a set of security rules to ensure that the passwords set by users meet certain strength and complexity requirements. If the system prompts that your password does not meet the password policy requirements, it usually means that your password does not meet the requirements set by Microsoft. standards for complexity, length, or character types, so how can this be avoided? Users can directly find the password policy under the local computer policy to perform operations. Let’s take a look below. Solutions that do not comply with password policy specifications: Change the password length: According to the password policy requirements, we can try to increase the length of the password, such as changing the original 6-digit password to 8-digit or longer. Add special characters: Password policies often require special characters such as @, #, $, etc. I

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

BitgetLaunchpool is a dynamic platform designed for all cryptocurrency enthusiasts. BitgetLaunchpool stands out with its unique offering. Here, you can stake your tokens to unlock more rewards, including airdrops, high returns, and a generous prize pool exclusive to early participants. What is BitgetLaunchpool? BitgetLaunchpool is a cryptocurrency platform where tokens can be staked and earned with user-friendly terms and conditions. By investing BGB or other tokens in Launchpool, users have the opportunity to receive free airdrops, earnings and participate in generous bonus pools. The income from pledged assets is calculated within T+1 hours, and the rewards are based on

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

How to add and manage users in Google Manager? Google Chrome supports multiple users to log in, so we don’t have to worry about logging in across devices. If we have many users, we need to add management. Some friends may not know how to operate. Don't worry, the editor has compiled a detailed step-by-step tutorial for everyone today. If you are interested, come and take a look with the editor. Detailed step-by-step tutorial instructions 1. After turning on the computer, find the installed Google Chrome icon on the desktop and double-click to open it, as shown in the picture below. 2. Click the three dots icon in the upper right corner of Google Chrome, as shown in the picture below. 3. Click the [Settings] option in the drop-down menu of Google Chrome, as shown in the figure below. 4. In the Google Chrome settings interface that opens, click [Manage ch
