Sets the crypt methods for encryption levels of type 4 or above.




XEncryption.SetCryptMethods(StringMethod [, StreamMethod])



Name Type Description
StringMethod Long The crypt method for strings. It is also for streams if StreamMethod is missing.
StreamMethod Long The crypt method for streams (optional).




The default crypt method for Type 4 is V2, which uses RC4 algorithm. Crypt method settings are in effect only when Type is 4 or higher.

The StringMethod and StreamMethod parameters can take any of the following values:

  • 0 [None] – (Not supported)
  • 1 [Identity] – No encryption
  • 2 [V2] – Uses the RC4 algorithm
  • 3 [AESV2] – Uses the AES algorithm with 128-bit encryption keys
  • 4 [AESV3] – Uses the AES algorithm with 256-bit encryption keys

Adobe Reader does not support using more than one crypt method per document (i.e. stringMethod≠streamMethod). However, Identity is degenerate and can be used with other crypt methods.




Here we use 128-bit AES encryption.

Set theDoc = Server.CreateObject("ABCpdf13.Doc")
theDoc.FontSize = 96
theDoc.AddText "Hello World!"
theDoc.Encryption.Type = 4
theDoc.Encryption.SetCryptMethods 3
theDoc.Save "c:\mypdfs\docencrypt.pdf"