Need help in aspEncrypt

Discussion in 'C#' started by costas408, Dec 5, 2008.

  1. #1
    Hi:

    This is related to programming, and I want to apply hash on my PDF filenaming, I create a function prototype something like this:

    'this is one file named PDFHash.asa


    <!--METADATA TYPE="TypeLib" UUID="{B72DF063-28A4-11D3-BF19-009027438003}"-->
    <%
    
    function PDFHash(filename, salt, type)
    
        dim cryptoManager, cryptoContext, cryptoHash
    
        set cryptoManager = server.createobject("Persits.CryptoManager")
        set cryptoContext = cryptoManager.openContext("mycontainer", true)
        set cryptoHash = cryptoContext.createHash(algorithm)
    
        cryptoHash.addText(salt & filename)
        filename = cryptoHash.value
    
        select case type
            case "MD5"
                algorithm = calgMD5
            case else
                response.write "no algorithm"       
        end select
       
    end function
    %>
    PHP:
    'note: salt is declared as constant in one file called constant.asa:
    const salt = "ballpen"
    PHP:



    'another file calling this function, i just copy the line that relates above

        dim filename, cryptoSalt
       
        filename = trim(prtLastName) & "_" & left(trim(prtFirstName), 1) & "_" & prtID
        filename = PDFHash(filename, cryptoSalt, "MD5")
        filename = trim(prtLastName) & "_" & filename & ".pdf"   
    
    
    PHP:
    now, upon executing the page, it says:

    Microsoft VBScript compilation error '800a03f2'

    Expected identifier

    /Includes/PDFFilenameHash.asa, line 6

    function PDFHash(filename, salt, type)
    ---------------------------------^


    argument type will be a string, which do a switch statement on to determine the algorithm. only "MD5" is supported and evaluates to 32771.


    Please correct my code. Thanks.



    Helen Costas
     
    costas408, Dec 5, 2008 IP
  2. vihutuo

    vihutuo Well-Known Member

    Messages:
    1,511
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    180
    #2
    You may want to change the name 'type' to something else as it is a reserved word
     
    vihutuo, Dec 7, 2008 IP
  3. johnbelly

    johnbelly Peon

    Messages:
    104
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I get lot of idea from here
    put your more asp information thank u.
     
    johnbelly, Dec 9, 2008 IP