
package fortuna.generator;

/**
 *
 * @author Viliam Krizan
 */

//Counter mainly created for the aes cipher to operate
public class Counter {
    private  byte[] cb;
    
    public Counter(int numberOfBytes){
        cb = new byte[numberOfBytes];
        for (int i = 0; i < cb.length; i++) {
            cb[i] = -128;
        }
    }
    
    public  byte[] getCounter(){
        return cb;
    }
    
    public  void incrementCounter(int i){
        if(i==cb.length){
            return;
        }
        
        if(cb[i] == 127){
            cb[i] = -128;
            incrementCounter(i+1);
        }else{
            ++cb[i];
        }
        
    }
}

