Jump to content

help in StringRegExpReplace


shai
 Share

Recommended Posts

i have encrypted string.

i want convert this string to normal string.

this is a encryption Key:

'$"' = '1'
'$#' = '2'
'$$' = '3'
'$%' = '4'
'$&' = '5'
'$'' = '6'
'$(' = '7'
'$)' = '8'
'$*' = '9'
'$!' = '0'
'&0' = '_'
'#.' = '-'
'#/' = '.'
''"' = 'a'
''#' = 'b'
''$' = 'c'
''%' = 'd'
''&' = 'e'
'''' = 'f'
''(' = 'g'
'')' = 'h'
''*' = 'i'
''+' = 'j'
'',' = 'k'
''-' = 'l'
''.' = 'm'
''/' = 'n'
''0' = 'o'
'(!' = 'p'
'("' = 'q'
'(#' = 'r'
'($' = 's'
'(%' = 't'
'(&' = 'u'
"('" = 'v'
'((' = 'w'
'()' = 'x'
'(*' = 'y'
'(+' = 'z'

for example if i have this string:

'"(&(%'0'*(%

i want convret to "aotuit"

thanks

Link to comment
Share on other sites

  • Developers

i want convret to "aotuit"

thanks

Great, so what have you got so far and what is giving problems?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

by now i using this code to split the string:

#include <Array.au3>

_ArrayDisplay(_StringChop('$"$!$#$!$$$!',2))

Func _StringChop($string, $size)
    
$count = Ceiling(StringLen($string)/$size)
Dim $array[$count+1], $start = 1
For $i = 1 To $count
    $array[$i] = StringMid($string, $start, $size)
    $start += $size
Next
$array[0] = $count
Return $array
EndFunc

but i dont know how i can convert it

Link to comment
Share on other sites

Try this.

; Substitution cipher
Local $aArray[39][2] = [['$"', '1'],['$#', '2'],['$$', '3'],['$%', '4'],['$&', '5'],["$'", '6'],['$(', '7'], _
        ['$)', '8'],['$*', '9'],['$!', '0'],['&0', '_'],['#.', '-'],['#/', '.'],['''"', 'a'],['''#', 'b'], _
        ['''$', 'c'],['''%', 'd'],['''&', 'e'],["''", 'f'],["'(", 'g'],["')", 'h'],["'*", 'i'],["'+", 'j'], _
        ["',", 'k'],["'-", 'l'],["'.", 'm'],["'/", 'n'],["'0", 'o'],["(!", 'p'],['("', 'q'],['(#', 'r'], _
        ['($', 's'],['(%', 't'],['(&', 'u'],["('", 'v'],['((', 'w'],['()', 'x'],['(*', 'y'],['(+', 'z']]

Local $sEncrypted = "'""(&(%'0'*(%"
Local $sDecrypted = _Decrypt($sEncrypted)
MsgBox(0, "Decryption", "Code: " & $sEncrypted & @CRLF & "Uncoded: " & $sDecrypted)

Local $sText = "AutoIt"
Local $sEncoded = _Encrypt($sText)
MsgBox(0, "Encryption", "Text: " & $sText & @CRLF & "Coded: " & $sEncoded)


Func _Decrypt($string)
    Local $aEncryped = StringRegExp($string, "(..)", 3)
    Local $sRet = ""
    For $i = 0 To UBound($aEncryped) - 1
        For $iF = 0 To UBound($aArray) - 1
            If $aArray[$iF][0] = $aEncryped[$i] Then $sRet &= $aArray[$iF][1]
        Next
    Next
    Return $sRet
EndFunc   ;==>_Decrypt

Func _Encrypt($string)
    Local $aDecryped = StringSplit(StringLower($string), "", 2)
    Local $sRet = ""
    For $i = 0 To UBound($aDecryped) - 1
        For $iF = 0 To UBound($aArray) - 1
            If $aArray[$iF][1] = $aDecryped[$i] Then $sRet &= $aArray[$iF][0]
        Next
    Next
    Return $sRet
EndFunc   ;==>_Encrypt
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...