public static byte[] getOutputPrefix(Key key) throws GeneralSecurityException {
    switch (key.getOutputPrefixType()) {
      case LEGACY: // fall through
      case CRUNCHY:
        return OutputPrefixUtil.getLegacyOutputPrefix(key.getKeyId()).toByteArray();
      case TINK:
        return OutputPrefixUtil.getTinkOutputPrefix(key.getKeyId()).toByteArray();
      case RAW:
        return RAW_PREFIX;
      default:
        throw new GeneralSecurityException("unknown output prefix type");
    }
  }
Generates the prefix of all cryptographic outputs (ciphertexts, signatures, MACs, ...) produced
by the specified {@code key}. The prefix can be either empty (for RAW-type prefix), or consists
of a 1-byte indicator of the type of the prefix, followed by 4 bytes of {@code key.key_id} in
Big Endian encoding.

@throws GeneralSecurityException if the prefix type of {@code key} is unknown.
@return a prefix.
java_src/src/main/java/com/google/crypto/tink/CryptoFormat.java