http://onion.net/2010/compression/zip

setPassword (password : string) : void

The generated .zip file can be given a password with the method »setPassword()«.

Hint

The password still has no influence whatsoever on opening the file! Only for unzipping is it necessary to enter the relevant correct password.

If the display of the file list is to be hidden already, then the .zip file must be rendered into a passwort-protected .zip again.

Parameter

The password to be set is transferred as a string to the parameter »password«.

Example

The following example demonstrates the use of the method »setPassword()«.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:b="http://onionworks.net/2004/renderengine/binary" xmlns:zip="http://onion.net/2010/compression/zip" xmlns:onion="http://onionworks.net/2004/data" version="1.0">
<xsl:template match="/">
<xsl:variable name="zip" select="zip:create(0, 'off')" />
<xsl:value-of select="zip:setPassword('onion.net')" />
<xsl:value-of select="zip:finish()" />
<b:output mimeType="application/zip">
<b:webResponse dispositionType="attachment" filename="test.zip" />
</b:output>
</xsl:template>
</xsl:stylesheet>

It is important for the method to be called directly after calling the method »create()«.

See also