     }
     
     return encoded
-}+}

public func Encode(bytes : [UInt8], alphabet : Alphabet = .Standard) -> [UInt8] {
    var encoded : [UInt8] = []
    
    let table = tableForAlphabet(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
        
        encoded.append(table[Int(one)])
        encoded.append(table[Int(two)])
        encoded.append(table[Int(three)])
        encoded.append(table[Int(four)])
    }
    
    if i+2 == count {

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