Ejemplo n.º 1
0
  private void addVersion(HashBlock block, String content) throws Exception {
    // 1 plain hash, plus 4 voters
    MessageDigest[] digests = new MessageDigest[5];
    // fake "Plain Hash"
    digests[0] = MessageDigest.getInstance("SHA1");
    digests[0].update(content.getBytes());
    // fake "Nonced Hash" for voter 1
    digests[1] = MessageDigest.getInstance("SHA1");
    digests[1].update(content.getBytes());
    // fake "Nonced Hash" for voter 2
    digests[2] = MessageDigest.getInstance("SHA1");
    digests[2].update(content.getBytes());
    // fake "Nonced Hash" for voter 3
    digests[3] = MessageDigest.getInstance("SHA1");
    digests[3].update(content.getBytes());
    // fake "Nonced Hash" for voter 4
    digests[4] = MessageDigest.getInstance("SHA1");
    digests[4].update(content.getBytes());

    block.addVersion(
        0,
        content.length(),
        0,
        content.length(),
        digests.length * content.length(), // total bytes hashed
        digests,
        hbVersionNum++,
        null);
  }
Ejemplo n.º 2
0
 private byte[] addVersion(VoteBlock block, String content) throws Exception {
   MessageDigest md = MessageDigest.getInstance("SHA1");
   md.update(content.getBytes());
   byte[] hash = md.digest();
   block.addVersion(0, content.length(), 0, content.length(), hash, hash, false);
   return hash;
 }