def digest(mechanism, data=nil, &block)
      C_DigestInit(mechanism)
      if block_given?
        raise "data not nil, but block given" if data
        yield DigestCipher.new(proc{|data_|
          C_DigestUpdate(data_)
        }, proc{|key_|
          C_DigestKey(key_)
        })
        C_DigestFinal()
      else
        C_Digest(data)
      end
    end
def digest(mechanism, data=nil, &block)
      C_DigestInit(mechanism)
      if block_given?
        raise "data not nil, but block given" if data
        yield DigestCipher.new(proc{|data_|
          C_DigestUpdate(data_)
        }, proc{|key_|
          C_DigestKey(key_)
        })
        C_DigestFinal()
      else
        C_Digest(data)
      end
    end
Convenience method for the {Session#C_DigestInit}, {Session#C_DigestUpdate}, {Session#C_DigestKey},
 {Session#C_DigestFinal} call flow.

 @example
   digest_string = session.digest( :SHA_1 ) do |cipher|
     cipher.update("key prefix")
     cipher.digest_key(some_key)
   end
 @param [Hash, Symbol, Integer, PKCS11::CK_MECHANISM] mechanism  used mechanism
 @param [String] data  data to digest
 @yield [PKCS11::Session::DigestCipher]  Cipher object for processing data parts
 @return [String]  final message digest
 @see Session#encrypt