 //  HashIds
 //
 //  Created by malczak on 04/02/15.
-//  Copyright (c) 2015 thepiratecat. All rights reserved.
+//  Copyright (c) 2015 thepiratecat.
 //
+//  Licensed under the MIT license.
+//
 
 import Foundation
 
+// MARK: Hashids options
+
+struct HashidsOpts
+{
+    static let VERSION = "1.0.0";
+    
+    static var MIN_ALPHABET_LENGTH:Int = 16;
+    
+    static var SEP_DIV:Double = 3.5;
+    
+    static var GUARD_DIV:Double = 12;
+    
+    static var ALPHABET:String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+    
+    static var SEPARATORS:String = "cfhistuCFHISTU";
+}
+
+
+// MARK: Hashids protocol
+
+protocol HashidsGenerator
+{
+    typealias Char;
+    
+    func encode(value:Int...) -> String?
+    
+    func encode(values:[Int]) -> String?
+    
+    func decode(value:String!) -> [Int]
+    
+    func decode(value:[Char]) -> [Int]
+    
+}
+
+
+// MARK: Hashids class
+
 typealias Hashids = Hashids_<UInt32>
 
-struct HashidsOpts
-{
-    static var MIN_ALPHABET_LENGTH:Int = 16;
-        
-    static var SEP_DIV:Double = 3.5;
-        
-    static var GUARD_DIV:Double = 12;
-    
-    static var ALPHABET:String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
-    
-    static var SEPARATORS:String = "cfhistuCFHISTU";
-}
-
-class Hashids_<T where T:Equatable, T:IntegerType, T:UnsignedIntegerType>
+
+// MARK: Hashids generic class
+
+class Hashids_<T where T:Equatable, T:UnsignedIntegerType> : HashidsGenerator
 {
     typealias Char = T;
     

            let rrange = half_length..<(alphabet.count);
            ret = alphabet[rrange] + ret + alphabet[lrange];
            
            let excess = ret.count - half_length;
            if( excess > 0 )
            {
                let start = excess >> 1;
                ret = [Char](ret[start..<(start+half_length)])
            }
        }
        

    }
   
}

// MARK: Internal functions

internal func contains<T:CollectionType where T.Generator.Element:Equatable>(a:T, e:T.Generator.Element) -> Bool
{
