         if (data.count > 0)
         {
             // Encode the data
-            data.withUnsafeBytes {
-                self.coders.encoder(UnsafeBufferPointer(start: $0, count: data.count),
+            data.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> Void in
+                let encoder = encode ? self.coders.encoder : FFDataWrapperEncoders.identity.coders.encoder
+                encoder(UnsafeBufferPointer(start: bytes, count: data.count),
                                     UnsafeMutableBufferPointer(start: self.dataRef.dataBuffer.baseAddress!, count: self.dataRef.dataBuffer.count))
             }
         }

    /// - Parameters:
    ///   - data: The data to wrap.
    ///   - coders: Pair of coders to use to convert to/from the internal representation. If nil, the default XOR coders will be used.
    public init(_ data: Data, _ coders: (encoder: FFDataWrapperCoder, decoder: FFDataWrapperCoder)? = nil)
    {
        self.coders = coders ?? FFDataWrapperEncoders.xorWithRandomVectorOfLength(data.count).coders
        

        
        self.coders = coders ?? FFDataWrapperEncoders.xorWithRandomVectorOfLength(actualLength).coders
        self.dataRef = FFDataRef(length: actualLength)
        let encoder = encode ? self.coders.encoder : FFDataWrapperEncoders.identity.coders.encoder
        encoder(UnsafeBufferPointer(start: tempBufferPtr, count: actualLength),
                UnsafeMutableBufferPointer(start: self.dataRef.dataBuffer.baseAddress!, count: self.dataRef.dataBuffer.count))
        
    }
    
