Simple encryption / decryption features in classic ASP

Are there any simple encryption / decryption features in classic ASP?

Data that needs to be encrypted and decrypted is not hypersensitive. Such simple functions could do.

+3
source share
2 answers

4guysfromrolla.com: RC4 encryption using ASP and VBScript

See attachments at the end of the page.

The page layout looks a little broken for me, but all the information is there. I made it readable by removing the code block from the DOM using the bowser development tools.

+4
source

Try the following:

' 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
0
source

Source: https://habr.com/ru/post/1758809/


All Articles