         return decodedBytes.count != 0 ? Data(bytes: UnsafePointer<UInt8>(decodedBytes), count: decodedBytes.count) : nil
     }
     
+    /** Encode some data of type `Data`.
+     
+    - parameter data: The input data.
+    - parameter coding: The decoding standard. Defaults to .standard.
+    - parameter padding: Add padding character if necessary. Defaults to .on.
+    - returns: A base64 encoded string. In case of failure nil.
+    */
     public static func encode(_ data: Data, coding: Base64Coding = .standard, padding: Base64Padding = .on) -> String? {
         if data.count == 0 { return nil }
         

}

public enum Base64Padding {
    case on, off
}

public enum Base64Error: Error {
    case containsIllegalCharacters, codingError
}

/** Provides base-64 en-/decoding for the standard and url safe alphabet.

        }
    }
    
    /** Finds, for a given character at index `idx` the corresponding
     translated value out of the alphabet.
         
    - parameter idx: The character index.
    - parameter string: The string itself.
    - returns: The corresponding translated value.
    */
    func decodedValue(forIndex idx: Int, inString string: String) -> UInt8? {
        let index = string.utf8.index(string.utf8.startIndex, offsetBy: idx)
        if let idxPoint = alphabet.index(of: string.utf8[index]) {
            return UInt8(idxPoint) & UInt8.max
        }
        return nil
    }
    
    /** Returns wether a given string contains only the allowed characters.
     Ignore padding if decoding is .urlSafe.
     
    - parameter string: The string object to be decoded.
    - parameter ignorePadding: Determines if character check ends before padding characters.
    - returns: Wether the string contains only allowed characters.
    */
    func stringContainsIllegalCharacters(_ string: String, ignorePadding: Bool = false) -> Bool {
        if let regEx = self.validityRegEx {
            var range = NSMakeRange(0, string.characters.count)
