Encrypt/Dencrypt Using ASC With Key In PowerBuilder
Encrypt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
//==================================================================== // Function: f_encrypt_asckey() //-------------------------------------------------------------------- // Description: encrypt a string in powerbuilder using asc type and key //-------------------------------------------------------------------- // Arguments: // value string as_key is key encrypt // value string as_string is string encrypt //-------------------------------------------------------------------- // Returns: string encrypt //==================================================================== String ls_rtncode,ls_code1,ls_code2,ls_temp Long ll_len,ll_i,ll_j Integer li_code1,li_code2 ll_len = LenA(as_string) If ll_len <= 0 Then Return "" ls_rtncode = "" ll_j = 1 For ll_i = 1 To ll_len li_code1 = AscA(MidA(as_string,ll_i,1)) li_code2 = AscA(MidA(as_key,ll_j,1)) li_code1 += li_code2 Do While li_code1 > 127 If li_code1 > 127 Then li_code1 = li_code1 - 127 End If Loop ls_temp = CharA(li_code1) ls_rtncode += ls_temp ll_j ++ If ll_j > LenA(as_key) Then ll_j = 1 Next Return ls_rtncode |
Dencrypt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
//==================================================================== // Function: f_dencrypt_asckey() //-------------------------------------------------------------------- // Description: dencrypt a string in powerbuilder using asc type and key //-------------------------------------------------------------------- // Arguments: // value string as_key is key dencrypt // value string as_string is string dencrypt //-------------------------------------------------------------------- // Returns: string dencrypt //==================================================================== String ls_rtncode,ls_code1,ls_code2,ls_temp Long ll_len,ll_i,ll_j Integer li_code1,li_code2 ll_len = LenA(as_string) If ll_len <= 0 Then Return "" ls_rtncode = "" ll_j = 1 For ll_i = 1 To ll_len li_code1 = AscA(MidA(as_string,ll_i,1)) li_code2 = AscA(MidA(as_key,ll_j,1)) li_code1 -= li_code2 Do While li_code1 < 0 If li_code1 < 0 Then li_code1 = li_code1 + 127 End If Loop ls_temp = CharA(li_code1) ls_rtncode += ls_temp ll_j ++ If ll_j > LenA(as_key) Then ll_j = 1 Next Return ls_rtncode |
Good Luck!
Subscribe
Login
0 Comments