def encrypt(mechanism, key, data=nil, &block)
      common_crypt(:C_EncryptInit, :C_EncryptUpdate, :C_EncryptFinal, :C_Encrypt,
                   mechanism, key, data, &block)
    end
def encrypt(mechanism, key, data=nil, &block)
      common_crypt(:C_EncryptInit, :C_EncryptUpdate, :C_EncryptFinal, :C_Encrypt,
                   mechanism, key, data, &block)
    end
Convenience method for the {Session#C_EncryptInit}, {Session#C_EncryptUpdate}, {Session#C_EncryptFinal} call flow.

 If no block is given, the single part operation {Session#C_EncryptInit}, {Session#C_Encrypt} is called.
 If a block is given, the multi part operation ({Session#C_EncryptInit}, {Session#C_EncryptUpdate}, {Session#C_EncryptFinal})
 is used. The given block is called once with a cipher object. There can be any number of
 {Cipher#update} calls within the block, each giving the encryption result of this part as String.

 @param [Hash, Symbol, Integer, PKCS11::CK_MECHANISM] mechanism  used mechanism
 @param [PKCS11::Object] key  used key
 @param [String] data  data to encrypt
 @yield [PKCS11::Session::Cipher]  Cipher object for processing data parts
 @return [String]  the final part of the encryption operation.

 @example for using single part operation
   iv = "12345678"
   cryptogram = session.encrypt( {:DES_CBC_PAD=>iv}, key, "block 1block 2" )

 @example for using multi part operation
   iv = "12345678"
   cryptogram = ''
   cryptogram << session.encrypt( {:DES_CBC_PAD=>iv}, key ) do |cipher|
     cryptogram << cipher.update("block 1")
     cryptogram << cipher.update("block 2")
   end

 @example Calculating a key check value to a secret key
     key_kcv = session.encrypt( :DES3_ECB, key, "\0"*8)