Cryptographic encryption and decryption principle of PB connection description file

Source: Internet
Author: User
Tags date decrypt integer lowercase

This paper expounds the principle of encrypting and decrypting the database connection description file under PB development environment.

Encryption principle: First invert the original string (reverse), one character for ASCII and from 10 to 16 into the value, and then to lowercase, the final end Plus ' 00 ' as a terminator. Decryption principle: Remove the end of ' 00 ', the original string inversion (reverse), every 2 characters from 16 to 10 into the value, that is, the ASCII value, according to ASCII characters, cumulative to a string, which is the real login password.

In a PB development environment to connect to a database, you must create a description file that has entries written in the registry Hkey_current_ Under Usersoftwaresybasepowerbuilder9.0databaseprofilespowerbuilder (different PB versions of different key paths), each description file corresponds to a registry item, describing the contents of the file such as user name and password as registry key stored in the corresponding registration Table items. Data is not encrypted except for the database password and login password. After a simple groping, found PB in the login password encryption, decryption is actually very simple.

The encryption principle can be described in this way. First, invert the original string (reverse), take ASCII one by one and convert from 10 to 16, then lowercase, and the end with ' 00 ' as the Terminator.

Understanding its encryption principle, it is easy to infer its decryption principle, its decryption principle can be described. Remove the end ' 00 ', invert the original string (reverse), and convert each 2 character from 16 to 10, which is the ASCII value, and accumulates to a string based on the ASCII character, which is the real login password.

The attached function can be used as a decryption reference code (development environment: PB9). You can call the function in the PB development environment without input user name or (and) password directly into the system, to avoid complex password memory, convenient for developers to run, test the system.

In addition, the Jaguar Server description file password also uses the same encryption and decryption mechanism, but the registry path is not the same.

Finally remind readers not to use the code for illegal purposes, resulting in the consequences or legal disputes I am not responsible for.

Attachment: Decrypt source code:

/****************************************
Function name: F_decryptpbpassword ()
Parameter: As_orginalpassword string original password
Return value: String decrypted text This article is from http://bianceng.cn (Getting started with programming)
Function Description: Decrypt PB database Connection description password
Create Person: Kangjianmin
Date Created: 2006-04-27
Version number: V1.0
*****************************************/
String Ls_temp,ls_return= '
Integer I,LI_COUNT,LI_ASCII
Nvo_numerical lnv_numerical
If Len (As_orginalpassword) < 2
or As_orginalpassword = ' then return '
As_orginalpassword = Left (reverse (As_orginalpassword),
Len (As_orginalpassword)-2)
Li_count = Ceiling (len (as_orginalpassword)/2)
For i = 1 to Li_count
Ls_temp = Mid (As_orginalpassword, (i-1) * 2 + 1,2)
Li_ascii = Lnv_numerical.of_hextodecimal (ls_temp)
Ls_temp = char (LI_ASCII)
Ls_return = Ls_return + ls_temp
Next
Return Ls_return
/********************************************
Function name: Of_hextodecimal ()
Parameters: As_hexdata String 16 Feed data
return value: Unsignedlong 10 binary data
Function Description: 16 into 10 data into the system data
Create Person: Kangjianmin
Date Created: 2006-04-27
Version number: V1.0
*********************************************/
Charlch_char[]
Unsignedlong lul_decimal=0
Integer li_dec[48 to), I, Li_len
For i = 57
Li_dec[i] = i-48
Next
For i = 70
Li_dec[i] = i-55
Next
As_hexdata = Lower (As_hexdata)
Lch_char = As_hexdata
Li_len = Len (as_hexdata)
For i = 1 to Li_len
Choose Case Lch_char[i]
Case ' 0 ' to ' 9 ', ' a ' to ' F '
Lul_decimal = Lul_decimal * + LI_DEC[ASC (Lch_char[i])]
Case Else
Return Lul_decimal
End Choose
Next
Return Lul_decimal

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.