public Context setKey(Key key) {
    Preconditions.checkNotNull(cipher, "Context does not have a cipher");
    // validate the key length
    byte[] encoded = key.getEncoded();
    if (encoded.length != cipher.getKeyLength()) {
      throw new RuntimeException(
        "Illegal key length, have=" + encoded.length + ", want=" + cipher.getKeyLength());
    }
    this.key = key;
    this.keyHash = new String(Hex.encodeHex(Encryption.computeCryptoKeyHash(conf, encoded)));
    return this;
  }
Crypto context. Encapsulates an encryption algorithm and its key material.
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/Context.java