AutoHotKey를 사용하여 클립보드를 통해 Hex를 base64로 암호화하려고 합니다.

AutoHotKey를 사용하여 클립보드를 통해 Hex를 base64로 암호화하려고 합니다.

강조 표시된 URL을 base64로 디코딩하는 코드를 얻었습니다.

이제 강조 표시된 16진수를 base64로 인코딩하고 싶지만 제대로 작동하지 않습니다. /

예를 들어, 16진수:가 있고 3648af61e4473d60d85481bf822a6d04316615efd6cd903d6bdc05b8c9ae58bfbabbb154099e345e4e12d770a774ad599420af221c26a7e0f21f9f1fc43a6d14 해당 base64를 인코딩하려고 합니다. 결과적으로 나는 얻는다

MzY0OGFmNjFlNDQ3M2Q2MGQ4NTQ4MWJmODIyYTZkMDQzMTY2MTVlZmQ2Y2Q5MDNkNmJkYzA1YjhjOWFlNThiZmJhYmJiMTU0MDk5ZTM0NWU0ZTEyZDc3MGE3NzRhZDU5OTQyMGFmMjIxYzI2YTdlMGYyMWY5ZjFmYzQzYTZkMTQ=

하지만 그래야만 해NkivYeRHPWDYVIG/giptBDFmFe/WzZA9a9wFuMmuWL+6u7FUCZ40Xk4S13CndK1ZlCCvIhwmp+DyH58fxDptFA==

지금까지 내가 가지고 있는 코드는 다음과 같습니다.

#SingleInstance, Force

;***********Decode URL******************* 
!d:: ;Alt+d will Decode highlighted text from URL to base64
gosub Store_Clipboard_Copy_Selected_Text
Clipboard:=URiDecode(clipboard) ;Decode URL
Gosub Paste_and_Restore_Stored_Clipboard ;restore clipboard
return



;***********Decode HEX******************* 
!f:: ;Alt+f will Encode highlighted text from Hex to base64
gosub Store_Clipboard_Copy_Selected_Text
Clipboard:=Base64Encode(clipboard) ; Encode HEX
Gosub Paste_and_Restore_Stored_Clipboard ;restore clipboard
return

;*******Store Clipboard- save for restoring, and copy selected text to clipboard****************
Store_Clipboard_Copy_Selected_Text:
Store:=ClipboardAll  ;Store full version of Clipboard
  clipboard = ; Empty the clipboard
  SendInput, ^c ;changd from Send  11/23
  ClipWait, 1
    If ErrorLevel ;Added errorLevel checking
      {
        MsgBox, No text was sent to clipboard
        Return
      }
return

;**********************restore clipboard*********************************
Paste_and_Restore_Stored_Clipboard:  ;put back original content
SendEvent , ^v
Clipboard:=Store
return

uriDecode(str) {
    Loop
 If RegExMatch(str, "i)(?<=%)[\da-f]{1,2}", hex)
    StringReplace, str, str, `%%hex%, % Chr("0x" . hex), All
    Else Break
 Return, str
}

Base64Encode(String)
{
    static CharSet := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
    VarSetCapacity(Output,Ceil(Length / 3) << 2)
    Index := 1, Length := StrLen(String)
    Loop, % Length // 3
    {
        Value := Asc(SubStr(String,Index,1)) << 16
            | Asc(SubStr(String,Index + 1,1)) << 8
            | Asc(SubStr(String,Index + 2,1))
        Index += 3
        Output .= SubStr(CharSet,(Value >> 18) + 1,1)
            . SubStr(CharSet,((Value >> 12) & 63) + 1,1)
            . SubStr(CharSet,((Value >> 6) & 63) + 1,1)
            . SubStr(CharSet,(Value & 63) + 1,1)
    }
    Length := Mod(Length,3)
    If Length = 0 ;no characters remaining
        Return, Output
    Value := Asc(SubStr(String,Index,1)) << 10
    If Length = 1
    {
        Return, Output ;one character remaining
            . SubStr(CharSet,(Value >> 12) + 1,1)
            . SubStr(CharSet,((Value >> 6) & 63) + 1,1) . "=="
    }
    Value |= Asc(SubStr(String,Index + 1,1)) << 2 ;insert the third character
    Return, Output ;two characters remaining
        . SubStr(CharSet,(Value >> 12) + 1,1)
        . SubStr(CharSet,((Value >> 6) & 63) + 1,1)
        . SubStr(CharSet,(Value & 63) + 1,1) . "="
}

올바른 결과를 얻는 방법과 코드에 어떤 문제가 있는지 알 수 없습니다. :(

관련 정보