net.i2p.data.Hash.toByteArray()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(242)

本文整理了Java中net.i2p.data.Hash.toByteArray()方法的一些代码示例,展示了Hash.toByteArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hash.toByteArray()方法的具体详情如下:
包路径:net.i2p.data.Hash
类名称:Hash
方法名:toByteArray

Hash.toByteArray介绍

暂无

代码示例

代码示例来源:origin: i2p/i2p.i2p

dsaEng.sign(Hash.FAKE_HASH.toByteArray(), session.getPrivateKey()).writeBytes(dout);
dout.write(DataHelper.getASCII("blah"));

代码示例来源:origin: i2p/i2p.i2p-bote

public static String toBase32(Hash hash) {
  return Base32.encode(hash.toByteArray());
}

代码示例来源:origin: i2p/i2p.i2p-bote

@Override
public byte[] toByteArray() {
  ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
  
  try {
    writeHeader(outputStream);
    outputStream.write(key.toByteArray());
  }
  catch (IOException e) {
    log.error("Can't write to ByteArrayOutputStream.", e);
  }
  
  return outputStream.toByteArray();
}

代码示例来源:origin: i2p/i2p.i2p-bote

@Override
  public byte[] toByteArray() {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    
    try {
      writeHeader(outputStream);
      outputStream.write(dhtKey.toByteArray());
    }
    catch (IOException e) {
      log.error("Can't write to ByteArrayOutputStream.", e);
    }
    
    return outputStream.toByteArray();
  }
}

代码示例来源:origin: i2p/i2p.i2p-bote

@Override
public byte[] toByteArray() {
  ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream();
  DataOutputStream dataStream = new DataOutputStream(byteArrayStream);
  try {
    writeHeader(dataStream);
    dataStream.write(dhtKey.toByteArray());
    dataStream.writeInt((int)(storeTime / 1000));   // store as seconds
    dataStream.write(delVerificationHash.toByteArray());
    dataStream.write(cryptoImpl.getId());
    dataStream.writeShort(encryptedData.length);
    dataStream.write(encryptedData);
  }
  catch (IOException e) {
    log.error("Can't write to ByteArrayOutputStream.", e);
  }
  return byteArrayStream.toByteArray();
}

代码示例来源:origin: i2p/i2p.i2p-bote

@Override
public byte[] toByteArray() {
  ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
  
  try {
    writeHeader(outputStream);
    // TODO doesn't the type code already get written in writeHeader?
    outputStream.write(getPacketTypeCode(dataType));
    outputStream.write(key.toByteArray());
  }
  catch (IOException e) {
    log.error("Can't write to ByteArrayOutputStream.", e);
  }
  
  return outputStream.toByteArray();
}

代码示例来源:origin: i2p/i2p.i2p-bote

@Override
public byte[] toByteArray() {
  ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
  
  try {
    writeHeader(outputStream);
    outputStream.write(dhtKey.toByteArray());
    outputStream.write(authorization.toByteArray());
  }
  catch (IOException e) {
    log.error("Can't write to ByteArrayOutputStream.", e);
  }
  
  return outputStream.toByteArray();
}

代码示例来源:origin: i2p/i2p.i2p-bote

@Override
public byte[] toByteArray() {
  ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
  DataOutputStream dataStream = new DataOutputStream(byteStream);
  try {
    writeHeader(dataStream);
    
    dataStream.writeInt(entries.size());
    for (DeletionRecord entry: entries) {
      dataStream.write(entry.dhtKey.toByteArray());
      dataStream.write(entry.delAuthorization.toByteArray());
      dataStream.writeInt((int)(entry.storeTime/1000L));   // store as seconds
    }
  }
  catch (IOException e) {
    log.error("Can't write to ByteArrayOutputStream/DataOutputStream.", e);
  }
  return byteStream.toByteArray();
}

代码示例来源:origin: i2p/i2p.i2p-bote

@Override
public byte[] toByteArray() {
  ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
  DataOutputStream dataStream = new DataOutputStream(byteStream);
  try {
    writeHeader(dataStream);
    
    destinationHash.writeBytes(dataStream);
    dataStream.writeInt(entries.size());
    for (IndexPacketEntry entry: entries) {
      dataStream.write(entry.emailPacketKey.toByteArray());
      dataStream.write(entry.delVerificationHash.toByteArray());
      dataStream.writeInt((int)(entry.storeTime/1000L));   // store as seconds
    }
  }
  catch (IOException e) {
    log.error("Can't write to ByteArrayOutputStream/DataOutputStream.", e);
  } catch (DataFormatException e) {
    log.error("Can't write destination hash to output stream: " + destinationHash, e);
  }
  return byteStream.toByteArray();
}

代码示例来源:origin: i2p/i2p.i2p-bote

@Override
public byte[] toByteArray() {
  ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
  DataOutputStream dataStream = new DataOutputStream(byteStream);
  
  try {
    writeHeader(dataStream);
    emailDestHash.writeBytes(dataStream);
    dataStream.writeShort(entries.size());
    for (Entry<Hash, UniqueId> entry: entries.entrySet()) {
      dataStream.write(entry.getKey().toByteArray());
      dataStream.write(entry.getValue().toByteArray());
    }
  } catch (DataFormatException e) {
    log.error("Invalid format for email destination.", e);
  } catch (IOException e) {
    log.error("Can't write to ByteArrayOutputStream.", e);
  }
  
  return byteStream.toByteArray();
}

代码示例来源:origin: i2p/i2p.i2p-bote

public static String toBase32(Destination destination) {
  return Base32.encode(destination.calculateHash().toByteArray());
}

代码示例来源:origin: i2p/i2p.i2p-bote

@Override
  public Collection<? extends DataPacket> split() {
    if (isTooBig()) {
      int bytesPerEntry = entries.get(0).emailPacketKey.toByteArray().length + entries.get(0).delVerificationHash.toByteArray().length + 4;   // see toByteArray()
      List<IndexPacket> subpackets = new ArrayList<IndexPacket>();
      IndexPacket currentSubpacket = new IndexPacket(destinationHash);
      for (IndexPacketEntry entry: entries) {
        if (currentSubpacket.getSize()+bytesPerEntry > MAX_DATAGRAM_SIZE) {
          subpackets.add(currentSubpacket);
          currentSubpacket = new IndexPacket(destinationHash);
        }
        currentSubpacket.put(entry);
      }
      subpackets.add(currentSubpacket);
      return subpackets;
    }
    else
      return Collections.singleton(this);
  }
}

代码示例来源:origin: i2p/i2p.i2p-bote

writeHeader(dataStream);
dataStream.write(nameHash.toByteArray());

代码示例来源:origin: i2p/i2p.i2p-bote

/**
 * Returns a byte array of length <code>NUM_FINGERPRINT_BYTES</code>.
 * @throws GeneralSecurityException
 */
private byte[] getRawFingerprint() throws GeneralSecurityException {
  byte[] input = Util.concat(nameHash.toByteArray(), destination.toByteArray());
  byte[] fingerprint = SCrypt.scrypt(input, salt, SCRYPT_PARAMETERS.N, SCRYPT_PARAMETERS.r, SCRYPT_PARAMETERS.p, NUM_FINGERPRINT_BYTES);
  return fingerprint;
}

代码示例来源:origin: i2p/i2p.i2p-bote

private static Fingerprint generate(Hash nameHash, EmailDestination destination) throws GeneralSecurityException {
  byte[] input = Util.concat(nameHash.toByteArray(), destination.toByteArray());
  RandomSource randomSource = I2PAppContext.getGlobalContext().random();
  while (true) {
    byte[] salt = new byte[NUM_SALT_BYTES];
    randomSource.nextBytes(salt);
    byte[] fingerprint = SCrypt.scrypt(input, salt, SCRYPT_PARAMETERS.N, SCRYPT_PARAMETERS.r, SCRYPT_PARAMETERS.p, NUM_FINGERPRINT_BYTES);
    if (fingerprint[NUM_FINGERPRINT_BYTES-1]==0 && (fingerprint[NUM_FINGERPRINT_BYTES-2]&3)==0)
      return new Fingerprint(nameHash, destination, salt);
  }
}

相关文章