Crypt::OpenPGP::S2k implements string-to-key generation for use in generating symmetric cipher keys from standard, arbitrary-length passphrases (like those used to lock secret key files). Since a passphrase can be of any length, and key material must be a very specific length, a method is needed to translate the passphrase into the key. The OpenPGP RFC defines three such methods, each of which this class implements.

Given a buffer $buffer of type Crypt::OpenPGP::Buffer, determines the type of S2k from the first octet in the buffer (one of the types listed above in new), then creates a new object of that type and initializes the S2k state from the buffer $buffer. Different initializations occur based on the type of S2k.