 public func Encode(bytes : [UInt8], alphabet : Alphabet = .Standard) -> [UInt8] {
     var encoded : [UInt8] = []
     
-    let table = tableForAlphabet(alphabet)
+    let table = tableForAlphabet(alphabet: alphabet)
     let padding = table[64]
     
-    var i = 0
     let count = bytes.count
     
-    for ; i+3 <= count; i += 3 {
-        let one = bytes[i] >> 2
-        let two = ((bytes[i] & 0b11) << 4) | ((bytes[i+1] & 0b11110000) >> 4)
-        let three = ((bytes[i+1] & 0b00001111) << 2) | ((bytes[i+2] & 0b11000000) >> 6)
-        let four = bytes[i+2] & 0b00111111
+    var i = 0
+    
+    for c in stride(from: 0,to:count, by: 3) {
+        let one = bytes[c] >> 2
+        let two = ((bytes[c] & 0b11) << 4) | ((bytes[c+1] & 0b11110000) >> 4)
+        let three = ((bytes[c+1] & 0b00001111) << 2) | ((bytes[c+2] & 0b11000000) >> 6)
+        let four = bytes[c+2] & 0b00111111
         
         encoded.append(table[Int(one)])
         encoded.append(table[Int(two)])
         encoded.append(table[Int(three)])
         encoded.append(table[Int(four)])
+        i = c
     }
     
     if i+2 == count {

    - returns: A String of the encoded bytes.
*/
public func EncodeString(bytes : [UInt8], alphabet : Alphabet = .Standard) -> String {
    let encoded = Encode(bytes, alphabet : alphabet)
    var result = String()
    for b in encoded {
        result.append(UnicodeScalar(b))
    }
    return result
}

    }
    
    return encoded
}
