Basic implementation of the counter mode