 /// The `String` extension defines methods to compute the message digest.
 extension String: MessageDigestProducible {
 
-    public func digest(algorithm: Digest.Algorithm) -> String {
-        let digest = Digest(algorithm)
+    /**
+     Produces the message digest.
+
+     - parameter algorithm: The cryptographic algorithm to use.
+
+     - returns:  the message digest (string of hexadecimal digits).
+     */
+    public func digest(algorithm: MessageDigest.Algorithm) -> String {
+        let digest = MessageDigest(algorithm)
         digest.update(self.dataUsingEncoding(NSUTF8StringEncoding)!.bytesArray())
         let messageDigest = digest.final()
-        return String(data: NSData(bytes: messageDigest, length: messageDigest.count), encoding: NSUTF8StringEncoding)!
+        return NSData(bytes: messageDigest, length: messageDigest.count).hexString()
     }
 
 }

    private let iv: IV?

    /**
     Initializes a new cryptor with the provided algorithm and options.

     - parameter algorithm: The symmetric algorithm to use for encryption
     - parameter options:   The encryption options.


     - returns: Encrypted data.
     */
    public func encrypt(algorithm: Cipher.Algorithm, options: Cipher.Options, key: NSData, iv: NSData? = nil) throws -> NSData {
        let cipher = Cipher(algorithm: algorithm, options: options, iv: iv?.bytesArray())
        let encryptedBytes = try cipher.encrypt(self.bytesArray(), key: key.bytesArray())
        return NSData(bytes: encryptedBytes, length: encryptedBytes.count)
    }

