Principles of password encryption and decryption for Pb database connection description files

Source: Internet
Author: User
[From network]

Describes the principles of password encryption and decryption for database connection description files in Pb development environments. Encryption principle: first, convert the original string (reverse), take ASCII characters one by one, convert them from decimal to hexadecimal, and then convert them into lowercase letters, end with '00. Decryption principle: remove the '00' at the end, and convert the original string (reverse). Every two characters are converted from hexadecimal to hexadecimal, that is, the ASCII value. Based on ASCII, accumulate to a string, which is the real logon password.

A description file must be created in advance to connect to the database in the Pb development environment, the description file entries are written in the Registry HKEY_CURRENT_USER \ Software \ Sybase \ PowerBuilder \ 9.0 \ databaseprofiles \ PowerBuilder (different key paths for different Pb versions). Each description file corresponds to a registry project, the content of the description file, such as the user name and password, is stored in the corresponding registry project as the registration key. Data is not encrypted except the Database Password and logon password. After a simple exploration, we found that Pb is actually very simple in encryption and decryption of login passwords.
The encryption principle can be described as follows. First, reverse the original string (reverse), take ASCII characters one by one, convert them from 10 to 16, convert them to lower case, and add '00' at the end as the end.

After learning about its encryption principle, it is easy to deduce its decryption principle. Its decryption principle can be described as follows. Remove the '00' at the end, and convert the original string (reverse). Every two characters are converted from hexadecimal to hexadecimal, that is, the ASCII value, accumulate to a string, which is the real logon password.

The attached function can be used as a reference for decryption. Code(Development Environment: pb9 ). You can call this function to directly access the system without entering the user name or (and) password in the Pb development environment, avoiding Complicated password memory and facilitating developers to run and test the system.

In addition, the password of the description file of the Jaguar server uses the same encryption and decryption mechanism, but the Registry path is different.

Finally, remind the reader not to use the code for illegal purposes. I am not responsible for the consequences or legal disputes arising therefrom.

Appendix: decryption Source code

/*************************************** ****************************

Function Name: f_decryptpbpassword ()

Parameter: as_orginalpassword string original password

Return Value: String decrypted text

Function Description: decrypts the password of the Pb database connection description.

Created by Kang Jianmin

Created on: 2006-04-27

Version: 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 = '00' 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 ()

Parameter: as_hexdata string hexadecimal data

Returned value: unsignedlong 10 hexadecimal data

Function Description: Convert hexadecimal data to hexadecimal data

Created by Kang Jianmin

Created on: 2006-04-27

Version: V1.0

**************************************** ***************************/

Char lch_char []

Unsignedlong lul_decimal = 0

Integer li_dec [48 to 70], I, li_len

For I = 48 to 57

Li_dec [I] = I-48

Next

For I = 65 to 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 * 16 + 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.