如何在vbScript中对函数名进行置乱

如何在vbScript中对函数名进行置乱,vbscript,asp-classic,Vbscript,Asp Classic,我想在定义函数时在源代码中隐藏函数名。我已经测试了以下逻辑,将名称分为两部分,但不起作用: function convertName(x) convertName= x & "tion" end function function convertName("myFunc")(text) convertName("myFunc")= text end function response.write myFunction("test") 有没有另一种方法来扰乱函数名?阅

我想在定义函数时在源代码中隐藏函数名。我已经测试了以下逻辑,将名称分为两部分,但不起作用:

function convertName(x)
    convertName= x & "tion"
end function

function convertName("myFunc")(text)
    convertName("myFunc")= text
end function

response.write myFunction("test")

有没有另一种方法来扰乱函数名?

阅读OP的问题注释我确信这不是OP需要的,Ansgar Wiechers完全正确,这只是使用了代码,但没有提供任何安全性,但它是如何处理请求的一种方法的示例

万一有人发现它有用,基本的想法是

Sub scrambledName( data )
    WScript.Echo data
End Sub 

    Set originalName = GetRef("scrambledName")
    originalName "this is a test"
也就是说,我们使用具有原始名称的变量来保存对加扰名称后面的代码的引用

作为示例:

Option Explicit

' Scrambled named code
'------------------------------------------------------------------------------
Sub Sbesttu29348( inputText )
    WScript.Echo "data=" & inputText
End Sub 

Function Fceinnostttu6953( a, b, c)
    Fceinnostttu6953 = a + b + c
End Function 
'------------------------------------------------------------------------------

    ' Map original names to scrambled ones
    prepareFunctions Array( "testSub", "testFunction" )

    ' Call functions using original names
    testSub "this is a test"
    WScript.Echo testFunction(1, 2, 3)


'Scramble handling code
'------------------------------------------------------------------------------
' Function used to find a scrambled name for the original function
' This simply concatenates input text sorted characters with a simple hash
Function scramble( inputText )
Dim a(256), i, s, h
    For i = 1 To LenB( inputText )
        s = AscB(MidB(inputText, i, 1)) 
        If s > 0 Then a(s) = a(s) & Chr(s)
        h = ((h\2)Xor(((h And 1)*65535)And&hffff))+s
    Next
    scramble = Trim(Join(a,"")) & h
End Function 

' Map original names to scrambled names
' It just defines new variables for the original names pointing to the scrambled names
Sub prepareFunctions( aFunctions )
Dim f, s
    For Each f in aFunctions
        s = s & "Set " & f & "=GetRef(""" & scramble(f) & """)" & vbCrLf
    Next 
    ExecuteGlobal s
End Sub
'------------------------------------------------------------------------------

你想炒什么?函数定义,函数调用,两者都有?正如我在上面写的,当我调用函数时,我用全名来调用它。我想在定义函数时对函数名进行置乱@好奇的麦克恩多:你为什么要这么做?别这么做。如果您的哈希函数允许在已知代码时还原哈希,则算法无效。加密哈希是单向函数,这意味着该操作不能是可逆的。通常不建议尝试使用自己的加密。坚持使用经过尝试和验证的实现。在这种情况下,hash将是一个错误的术语。你需要一个加密算法。然而,对于加密算法,安全性也不应取决于算法是否保密,而应仅取决于加密密钥。这就是克克霍夫原理。而且还是不建议使用你自己的密码。