2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
8 import java.nio.ByteBuffer;
9 import org.apidesign.spi.security.Digestor;
13 * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
15 // BEGIN: day.end.bridges.CountingDigestor
16 public final class CountingDigestor extends Digestor<int[]> {
18 protected byte[] digest(int[] data) {
20 byte[] arr = { (byte) (i & 255), (byte) ((i >> 8) & 255), (byte) ((i >> 16) & 255), (byte) ((i >> 24) & 255) };
25 protected int[] create(String algorithm) {
26 return "cnt".equals(algorithm) ? new int[1] : null; // NOI18N
30 protected void update(int[] data, ByteBuffer input) {
31 data[0] += input.remaining();
32 input.position(input.position() + input.remaining());
35 // END: day.end.bridges.CountingDigestor