Jump to content

Recommended Posts

Posted

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

Posted

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

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
  • Recently Browsing   0 members

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