AES Encrypted Self-Extracting Executable
This ASP script shows how to dynamically create an AES encrypted self-extracting executable and return it in the ASP Response
<%
' Return a self-extracting EXE created from in-memory data.
' Create a new instance of the ASP Zip compression component.
set zip = Server.CreateObject("Chilkat_9_5_0.Zip")
' Any value passed to UnlockComponent begins the 30-day trial.
unlocked = zip.UnlockComponent("30-day trial")
if unlocked then
' Initialize the object.
zip.NewZip "sfx.exe"
' Append some strings to the Zip
str = "Add this string as a file to the Zip object"
zip.AppendString "string-1.txt",str
str = "Here is another string to compress"
zip.AppendString "string-2.txt",str
Response.Buffer = True
Response.Expires = 0
Response.ContentType = "application/octet-stream"
Response.AddHeader "Content-transfer-encoding", "binary"
Response.AddHeader "Content-Disposition", "attachment;filename=sfx.exe"
' Set the password and indicate that we want the output to be AES encrypted.
zip.SetPassword "myPassword"
' The key length can be 128, 192, or 256
zip.EncryptKeyLength = 128
' Choose an encryption algorithm.
' 0 = none, 1 = blowfish, 2 = twofish, 3 = AES (rijndael)
zip.Encryption = 3
' When writing self-extracting executables, the Chilkat Zip component uses
' a temporary directory. You will want to control the
' location of this directory to make sure the Zip component
' has permission in ASP.
zip.TempDir = "c:/temp"
' Customize our SFX a bit...
zip.ExeTitle = "This is my self-extractor!"
' There are also features to:
' 1) Use a custom icon
' 2) Automatically run an EXE from within the SFX after extracting.
' 3) Automatically extract to a pre-set directory path.
' 4) Automatically extract with no prompting or interface.
' 5) Create AES encrypted self-extracting executables.
' Write the Zip as a self-extracting executable
' Returns 1 for success, 0 for failure.
success = zip.WriteExe("c:/temp/sfx.exe")
' Load the executable we just created into memory. Use the ChilkatCharset
' component for the ReadFile convenience method, which makes it easy
' to load binary files in ASP. Chilkat Charset is a licensed (non-free)
' component, so you may wish to load the binary file into memory in
' another way.
set cc = Server.CreateObject("Chilkat_9_5_0.Charset2")
cc.UnlockComponent("30-day trial")
exeImage = cc.ReadFile("c:/temp/sfx.exe")
' Write the SFX to the ASP response
Response.BinaryWrite(exeImage)
Response.Flush()
end if
%>
|