             
             result.appendData(encrypted)
             
-            // Convert to a string
-            var resultString = result.base64EncodedStringWithOptions(.allZeros)
-            
-            if urlEncode {
-                resultString = resultString.stringByReplacingOccurrencesOfString("/", withString: "_")
-                resultString = resultString.stringByReplacingOccurrencesOfString("+", withString: "-")
-            }
-            
-            return resultString
+            return result
         }
         
         return nil

    /// :returns: true if the signature is valid (and can be validated)
    ///
    public func verify(message: String, var signatureBase64: String, urlEncoded: Bool = true) -> Bool {
        if let key = obtainKey(.Public) {
            if urlEncoded {
                signatureBase64 = signatureBase64.stringByReplacingOccurrencesOfString("_", withString: "/")
                signatureBase64 = signatureBase64.stringByReplacingOccurrencesOfString("-", withString: "+")
            }
            
            if let signature = NSData(base64EncodedString: signatureBase64, options: .allZeros),
                messageData = message.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false),
                hashData = NSMutableData(length: Int(CC_SHA256_DIGEST_LENGTH)) {
                    
                CC_SHA256(messageData.bytes, CC_LONG(messageData.length), UnsafeMutablePointer(hashData.mutableBytes))
                
                let signedData = UnsafePointer<UInt8>(hashData.bytes)
                let signatureLength = Int(signature.length)
                let signatureData = UnsafePointer<UInt8>(signature.bytes)
                
                let result = SecKeyRawVerify(key, SecPadding(kSecPaddingPKCS1SHA256), signedData, Int(CC_SHA256_DIGEST_LENGTH), signatureData, signatureLength)
                
                switch result {
                case noErr:
                    return true
                default:
                    return false
                }
            }
        }
        

    /// Decrypt a Base64 string representation of encrypted data
    ///
    /// :param: base64String    string containing Base64 data to decrypt
    /// :param: urlEncoded      whether the input Base64 data is URL encoded
    ///
    /// :returns: Decrypted string as plain text
    ///
    public func decrypt(var base64String: String, urlEncoded: Bool = true) -> String? {
        if urlEncoded {
            base64String = base64String.stringByReplacingOccurrencesOfString("_", withString: "/")
            base64String = base64String.stringByReplacingOccurrencesOfString("-", withString: "+")
        }
        
        if let data = NSData(base64EncodedString: base64String, options: .allZeros), decryptedData = self.decrypt(data) {
            return NSString(data: decryptedData, encoding: NSUTF8StringEncoding) as? String
        }
        
        return nil
    }
    
    ///
    /// Decrypt the encrypted data
    ///
    /// :param: encryptedData   Data to decrypt
    ///
    /// :returns: The decrypted data, or nil if failed
    ///
    public func decrypt(encryptedData: NSData) -> NSData? {
        if let key = obtainKey(.Private) {
            // First block size should be the encrypted AES key
            let blockSize = SecKeyGetBlockSize(key)
            let keyData = encryptedData.subdataWithRange(NSRange(location: 0, length: blockSize))
            let messageData = encryptedData.subdataWithRange(NSRange(location: blockSize, length: encryptedData.length - blockSize))
            
            // Decrypt the key
            if let decryptedKey = NSMutableData(length: blockSize) {
                let encryptedKeyData = UnsafePointer<UInt8>(keyData.bytes)
                var decryptedKeyData = UnsafeMutablePointer<UInt8>(decryptedKey.mutableBytes)
                var decryptedLength = blockSize
                
                let keyStatus = SecKeyDecrypt(key, SecPadding(kSecPaddingPKCS1), encryptedKeyData, keyData.length, decryptedKeyData, &decryptedLength)
                
                if keyStatus == noErr {
                    decryptedKey.length = Int(decryptedLength)
                    
                    // Decrypt the message
                    if let message = Heimdall.decrypt(messageData, key: decryptedKey) {
                        return message
                    }
                }
            }
