1 package civitas.crypto.algorithms;
2
3 import org.springframework.beans.factory.annotation.Autowired;
4 import org.springframework.stereotype.Controller;
5
6 import civitas.crypto.CryptoBase;
7
8 @Controller
9 public class CreateFreshNonce {
10
11 @Autowired
12 CryptoBase cryptoBase;
13
14 public byte[] apply(final int bitlength) {
15 int bytelength = bitlength / 8;
16 if (bitlength % 8 != 0) {
17 bytelength++;
18 }
19 byte[] bs = new byte[bytelength];
20 cryptoBase.nextBytes(bs);
21 return bs;
22 }
23 }