All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.kafkacrypto.msgs.CryptoKeyFileFormat Maven / Gradle / Ivy

Go to download

Java port of kafkacrypto, a lightweight and cross-platform/cross-language encryption library for Apache Kafka.

There is a newer version: 0.9.11.0
Show newest version
package org.kafkacrypto.msgs;

import org.kafkacrypto.Utils;
import org.kafkacrypto.msgs.msgpack;
import org.kafkacrypto.msgs.Msgpacker;

import org.msgpack.core.MessagePacker;
import java.util.List;
import org.msgpack.value.Value;

import java.io.IOException;

public class CryptoKeyFileFormat implements Msgpacker
{
  public byte[] ssk;
  public byte[] ek;

  public CryptoKeyFileFormat unpackb(List src)
  {
    this.ssk = src.get(0).asRawValue().asByteArray();
    this.ek = src.get(1).asRawValue().asByteArray();
    return this;
  }

  public void packb(MessagePacker packer) throws IOException
  {
    packer.packArrayHeader(2);
    msgpack.packb_recurse(packer, this.ssk);
    msgpack.packb_recurse(packer, this.ek);
  }

  public String toString()
  {
    StringBuilder sb = new StringBuilder();
    sb.append("CKFF: [");
    sb.append(Utils.bytesToHex(this.ssk));
    sb.append(", ");
    sb.append(Utils.bytesToHex(this.ek));
    sb.append("]");
    return sb.toString();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy