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

org.signal.zkgroup.profiles.ProfileKeyVersion Maven / Gradle / Ivy

The newest version!
//
// Copyright 2020-2021 Signal Messenger, LLC.
// SPDX-License-Identifier: AGPL-3.0-only
//

package org.signal.zkgroup.profiles;

import org.signal.zkgroup.InvalidInputException;
import org.signal.zkgroup.internal.ByteArray;
import java.io.UnsupportedEncodingException;

public final class ProfileKeyVersion {

  private byte[] contents;

  public ProfileKeyVersion(byte[] contents) throws InvalidInputException {
    if (contents.length != 64) {
      throw new InvalidInputException("bad length");
    }
    this.contents = contents.clone();
  }

  public ProfileKeyVersion(String contents) throws InvalidInputException, UnsupportedEncodingException {
    this(contents.getBytes("UTF-8"));
  }

  public String serialize() {
    try {
      return new String(contents, "UTF-8");
    } catch (UnsupportedEncodingException e) {
      throw new AssertionError();
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy