     
     for i in 0 ..< data.length {
         data.getBytes(&byte, range: NSMakeRange(i, 1))
-        s.appendFormat("%02X", byte)
+        s.appendFormat("%02x", byte)
     }
     
     return s as String

    }
}

func typeToBytes <T> (var value: T) -> [UInt8] {
    return withUnsafePointer(&value) {
        Array(UnsafeBufferPointer(start: UnsafePointer<UInt8>($0), count: sizeof(T)))
    }
}

    
    var n = 0 // repeat counter
    
    var mutableFormat = format
    
    mutableFormat.removeAtIndex(mutableFormat.startIndex) // consume byte-order specifier
    
    while mutableFormat.characters.count > 0 {
        
        let c = mutableFormat.removeAtIndex(mutableFormat.startIndex)
        
        if let i = Int(String(c)) where 0...9 ~= i {
            if n > 0 { n *= 10 }
            n += i
            continue
