Create new mac based on a valid bit length from {@link Mac} class.

@return The mac
@throws IOException
For any unexpected exceptions
557069
private Mac create()
        throws IOException {
        final String algo = String.format("HmacSHA%s", this.bits);
        try {
            final SecretKeySpec secret = new SecretKeySpec(
                this.key, algo
            );
            final Mac mac = Mac.getInstance(algo);
            mac.init(secret);
            return mac;
        } catch (final NoSuchAlgorithmException | InvalidKeyException ex) {
            throw new IOException(ex);
        }
    }
436431
public Mac getMac(final @NotNull String alias) {
        try {
            Mac mac = Mac.getInstance(getAlgorithm(alias));
            mac.init(new SecretKeySpec(secret, mac.getAlgorithm()));

            return mac;
        } catch (NoSuchAlgorithmException | InvalidKeyException e) {
            throw new RuntimeException(e);
        }
    }
1110137
public static <S> PAreaSizeBIGenerator<S> create()
  {
    final LongGenerator gen = new LongGenerator(0L, Long.MAX_VALUE);
    return new PAreaSizeBIGenerator<>(() -> new BigInteger(gen.next().toString()));
  }
245205
public File output() throws IOException {
        File o = new File(output);
        if (!o.exists() && !o.mkdirs()) {
            throw new IOException("Unable to create output folder '" + output + "'");
        }
        return o;
    }
1036751
private Response make() throws IOException {
        if (this.transformed.isEmpty()) {
            this.transformed.add(
                new RsWithBody(
                    this.origin,
                    RsPrettyJson.transform(this.origin.body())
                )
            );
        }
        return this.transformed.get(0);
    }
1284701
public static DynamicByteBuffer create(byte[] buffer ) {
        DynamicByteBuffer buf = new DynamicByteBuffer( buffer.length );
        buf.buffer = buffer;
        return buf;
    }
828644
public WritableByteChannel create(URI path) throws IOException {
    logger.atFine().log("create(%s)", path);
    return create(path, CreateFileOptions.DEFAULT);
  }
240826
public static <I, O> Example<I, O> create(I input, O output) {
    return new Example<I, O>(input, output);
  }
728408
MAC newReadMAC() throws NoSuchAlgorithmException, InvalidKeyException {
        MacAlg macAlg = cipherSuite.macAlg;
        MAC mac;
        if (isClient) {
            mac = macAlg.newMac(protocolVersion, svrMacSecret);
            svrMacSecret = null;
        } else {
            mac = macAlg.newMac(protocolVersion, clntMacSecret);
            clntMacSecret = null;
        }
        return mac;
    }
1157735
public int expectUInt16() throws IOException {
        int b1 = in.read();
        if (b1 < 0) {
            throw new IOException("Missing byte 1 to expected uint16");
        }
        int b2 = in.read();
        if (b2 < 0) {
            throw new IOException("Missing byte 2 to expected uint16");
        }
        return unshift2bytes(b1, b2);
    }
715909
long write(OutputStream out) throws IOException {
    // decode macbinary if this was sent
    if (contentType.equals("application/x-macbinary")) {
      out = new MacBinaryDecoderOutputStream(out);
    }
    long size=0;
    int read;
    byte[] buf = new byte[8 * 1024];
    while((read = partInput.read(buf)) != -1) {
      out.write(buf, 0, read);
      size += read;
    }
    return size;
  }
916198
public ByteArray create( int size )
    {
        if ( size < 1 )
        {
            throw new IllegalArgumentException( "Buffer size must be at least 1: " + size );
        }
        int bits = bits( size );
        synchronized ( this )
        {
            if ( !freeBuffers.isEmpty() )
            {
                DirectBufferByteArray ba = freeBuffers.get( bits ).pop();
                ba.setFreed( false );
                ba.getSingleIoBuffer().limit( size );
                return ba;
            }
        }
        IoBuffer bb;
        int bbSize = 1 << bits;
        bb = IoBuffer.allocate( bbSize, direct );
        bb.limit( size );
        DirectBufferByteArray ba = new DirectBufferByteArray( bb );
        ba.setFreed( false );
        return ba;
    }
913717
public static IOException create(String msg, IOException exn)
  {
    if (exn.getClass().equals(IOException.class)
        || exn.getClass().equals(java.net.SocketException.class)
        || exn.getClass().getName().equals("javax.net.ssl.SSLException")) {
      return new ClientDisconnectException(msg, exn);
    }
    else
      return exn;
  }
1317543
public int expectUInt24() throws IOException {
        int b1 = in.read();
        if (b1 < 0) {
            throw new IOException("Missing byte 1 to expected uint24");
        }
        int b2 = in.read();
        if (b2 < 0) {
            throw new IOException("Missing byte 2 to expected uint24");
        }
        int b3 = in.read();
        if (b3 < 0) {
            throw new IOException("Missing byte 3 to expected uint24");
        }
        return unshift3bytes(b1, b2, b3);
    }
549064
@Override
    public InitialAddressMessage createIAM() {
        InitialAddressMessage msg = new InitialAddressMessageImpl(_IAM_HOLDER.mandatoryCodes,
                _IAM_HOLDER.mandatoryVariableCodes, _IAM_HOLDER.optionalCodes, _IAM_HOLDER.mandatoryCodeToIndex,
                _IAM_HOLDER.mandatoryVariableCodeToIndex, _IAM_HOLDER.optionalCodeToIndex);
        return msg;
    }
152079
def _generate_MAC(segments=6, segment_length=2, delimiter=":", charset="0123456789abcdef"):
        """"""
        addr = []
        for _ in range(segments):
            sub = ''.join(random.choice(charset) for _ in range(segment_length))
            addr.append(sub)
        return delimiter.join(addr)
892287
public static <T> T newInstance(Class<T> clazz) throws MjdbcException {
        try {
            return clazz.newInstance();

        } catch (InstantiationException ex) {
            throw new MjdbcException(
                    "Failed to create instance: " + clazz.getName() + " - " + ex.getMessage());

        } catch (IllegalAccessException ex) {
            throw new MjdbcException(
                    "Failed to create instance: " + clazz.getName() + " - " + ex.getMessage());
        }
    }