2022년 5월 2일 월요일

ASP - 암호화/암호 해독 기능


' Encrypt and decrypt functions for classic ASP (by TFI)


'********* set a random string with random length ***********

cryptkey = "GNQ?4i0-*\CldnU+[vrF1j1PcWeJfVv4QGBurFK6}*l[H1S:oY\v@U?i,oD]f/n8oFk6NesH--^PJeCLdp+(t8SVe:ewY(wR9p-CzG<,Q/(U*.pXDiz/KvnXP`BXnkgfeycb)1A4XKAa-2G}74Z8CqZ*A0P8E[S`6RfLwW+Pc}13U}_y0bfscJ<vkA[JC;0mEEuY4Q,([U*XRR}lYTE7A(O8KiF8>W/m1D*YoAlkBK@`3A)trZsO5xv@5@MRRFkt\"


'**************************** ENCRYPT FUNCTION ******************************


'*** Note: bytes 255 and 0 are converted into the same character, in order to

'*** avoid a char 0 which would terminate the string


function encrypt(inputstr)

        Dim i,x

        outputstr=""

        cc=0

        for i=1 to len(inputstr)

                x=asc(mid(inputstr,i,1))

                x=x-48

                if x<0 then x=x+255

                x=x+asc(mid(cryptkey,cc+1,1))

                if x>255 then x=x-255

                outputstr=outputstr&chr(x)

                cc=(cc+1) mod len(cryptkey)

        next

        encrypt=server.urlencode(replace(outputstr,"%","%25"))

end function


'**************************** DECRYPT FUNCTION ******************************


function decrypt(byval inputstr)

        Dim i,x

        inputstr=urldecode(inputstr)

        outputstr=""

        cc=0

        for i=1 to len(inputstr)

                x=asc(mid(inputstr,i,1))

                x=x-asc(mid(cryptkey,cc+1,1))

                if x<0 then x=x+255

                x=x+48

                if x>255 then x=x-255

                outputstr=outputstr&chr(x)

                cc=(cc+1) mod len(cryptkey)

        next

        decrypt=outputstr

end function


'****************************************************************************


Function URLDecode(sConvert)

  Dim aSplit

  Dim sOutput

  Dim I

  If IsNull(sConvert) Then

         URLDecode = ""

         Exit Function

  End If

  'sOutput = REPLACE(sConvert, "+", " ") ' convert all pluses to spaces

  sOutput=sConvert

  aSplit = Split(sOutput, "%") ' next convert %hexdigits to the character

  If IsArray(aSplit) Then

        sOutput = aSplit(0)

        For I = 0 to UBound(aSplit) - 1

          sOutput = sOutput &  Chr("&H" & Left(aSplit(i + 1), 2)) & Right(aSplit(i + 1), Len(aSplit(i + 1)) - 2)

        Next

  End If

  URLDecode = sOutput

End Function


출처 : https://code-examples.net/ko/q/348e47



javascript - SQL 예약어 제거

  <script language="javascript"> //특수문자, 특정문자열(sql예약어) 제거 function checkSearchedWord(obj){ obj.value = obj.value+&quo...