Encode/Decode Using ASC In PowerBuilder
Source Code
Encode ASC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Int i String ls_text,ls_text_after = '' Long ll_asc String as_string as_string = 'https://pblib.com/' If lenA(Trim(as_string)) < 0 Then Return '' For i = 1 To Len(Trim(as_string)) ls_text = Mid(as_string,i,1) ll_asc = Asc(ls_text) -(2*i) - 25 ls_text_after = ls_text_after +Char(ll_asc) Next //Return ls_text_after |
Decode ASC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Int i String ls_text,ls_text_after = '' Long ll_asc String as_string as_string = 'MWUOPEE@6?,64.1(,"/!&&#ᅴᅯ' If Len(Trim(as_string)) < 0 Then Return '' For i = 1 To Len(Trim(as_string)) ls_text = Mid(as_string,i,1) ll_asc = Asc(ls_text) +(2*i) + 25 ls_text_after = ls_text_after + Char(ll_asc) Next //Return ls_text_after |
Source Example
w_main from window
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
forward global type w_main from window end type type st_3 from statictext within w_main end type type st_2 from statictext within w_main end type type mle_output from multilineedit within w_main end type type mle_input from multilineedit within w_main end type type cb_decode from commandbutton within w_main end type type cb_encode from commandbutton within w_main end type end forward global type w_main from window integer width = 2318 integer height = 1168 boolean titlebar = true string title = "Encrypt/Dencrypt ASC" boolean controlmenu = true boolean minbox = true boolean maxbox = true boolean resizable = true long backcolor = 67108864 string icon = "AppIcon!" boolean center = true st_3 st_3 st_2 st_2 mle_output mle_output mle_input mle_input cb_decode cb_decode cb_encode cb_encode end type global w_main w_main type prototypes end prototypes forward prototypes public function string wf_encode (string as_string) public function string wf_decode (string as_string) end prototypes public function string wf_encode (string as_string);//==================================================================== // Function: w_main.wf_encode() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value string as_string //-------------------------------------------------------------------- // Returns: string //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2022/01/06 //-------------------------------------------------------------------- // Usage: w_main.wf_encode ( string as_string ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== Int i String ls_text,ls_text_after = '' Long ll_asc If lenA(Trim(as_string)) < 0 Then Return '' For i = 1 To Len(Trim(as_string)) ls_text = Mid(as_string,i,1) ll_asc = Asc(ls_text) -(2*i) - 25 ls_text_after = ls_text_after +Char(ll_asc) Next Return ls_text_after end function public function string wf_decode (string as_string);//==================================================================== // Function: w_main.wf_decode() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value string as_string //-------------------------------------------------------------------- // Returns: string //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2022/01/06 //-------------------------------------------------------------------- // Usage: w_main.wf_decode ( string as_string ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== Int i String ls_text,ls_text_after = '' Long ll_asc If Len(Trim(as_string)) < 0 Then Return '' For i = 1 To Len(Trim(as_string)) ls_text = Mid(as_string,i,1) ll_asc = Asc(ls_text) +(2*i) + 25 ls_text_after = ls_text_after + Char(ll_asc) Next Return ls_text_after end function on w_main.create this.st_3=create st_3 this.st_2=create st_2 this.mle_output=create mle_output this.mle_input=create mle_input this.cb_decode=create cb_decode this.cb_encode=create cb_encode this.Control[]={this.st_3,& this.st_2,& this.mle_output,& this.mle_input,& this.cb_decode,& this.cb_encode} end on on w_main.destroy destroy(this.st_3) destroy(this.st_2) destroy(this.mle_output) destroy(this.mle_input) destroy(this.cb_decode) destroy(this.cb_encode) end on type st_3 from statictext within w_main integer x = 64 integer y = 536 integer width = 343 integer height = 76 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "Output Text:" boolean focusrectangle = false end type type st_2 from statictext within w_main integer x = 64 integer y = 20 integer width = 329 integer height = 76 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "Input Text:" boolean focusrectangle = false end type type mle_output from multilineedit within w_main integer x = 50 integer y = 624 integer width = 2167 integer height = 400 integer taborder = 20 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 borderstyle borderstyle = stylelowered! end type type mle_input from multilineedit within w_main integer x = 50 integer y = 100 integer width = 2167 integer height = 400 integer taborder = 10 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 string text = "https://pblib.com/" borderstyle borderstyle = stylelowered! end type type cb_decode from commandbutton within w_main integer x = 1902 integer y = 512 integer width = 297 integer height = 96 integer taborder = 20 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "Decode" end type event clicked;String ls_input, ls_output ls_input = mle_input.Text ls_output = wf_decode(ls_input) mle_output.Text = ls_output end event type cb_encode from commandbutton within w_main integer x = 1573 integer y = 512 integer width = 297 integer height = 96 integer taborder = 10 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "Encode" end type event clicked;String ls_input, ls_output ls_input = mle_input.Text ls_output = wf_encode(ls_input) mle_output.Text = ls_output end event |
Find Projects On Github click here
Good Luck!
Subscribe
Login
0 Comments
Oldest