                 let seps_index = number % self.seps.count;
                 ret.append(self.seps[seps_index]);
             }
+            
+            lsalt.replaceRange(lsaltARange, with: alphabet);
         }
         
         let minLength:Int = numericCast(self.minHashLength);

            let excess = ret.count - half_length;
            if( excess > 0 )
            {
                let start = excess>>1;
                ret = [UInt32](ret[start..<(start+half_length)])
            }
        }
        
        return ret;
    }
    
    func _decode(hash:[UInt32]) -> [Int]
    {
        var ret = [Int]();
        
        var alphabet = self.alphabet;

        var hashes = split(hash, { contains(self.guards, $0) }, maxSplit: hash.count, allowEmptySlices: true);
        
        let hashesCount = hashes.count, i = ((hashesCount == 2) || (hashesCount == 3)) ? 1 : 0;
        
        let hash = hashes[i];
        if(hash.count > 0)
        {
            let lottery = hash[0];
            let valuesHashes = hash[1..<hash.count];
            var valueHashes = split(valuesHashes, { contains(self.seps, $0) }, maxSplit: valuesHashes.count, allowEmptySlices: true);
            
            for subHash in valueHashes
            {
                let lsalt = ([lottery] + self.salt + alphabet)[0..<(alphabet.count)];
                shuffle(&alphabet, lsalt);
                ret.append(self._unhash(subHash, alphabet));
            }
        }
        
        return ret;
    }
    
    func _hash(var number:Int, _ alphabet:[UInt32]) -> [UInt32]
    {
        var hash = [UInt32]();
        let length = alphabet.count
        
        do {


class Hashids
{
    typealias Char = UInt32;
    
    private let MIN_ALPHABET_LENGTH:Int = 16;
    
    private let SEP_DIV:Double = 3.5;
