code: public static byte[] closeBox(byte[] header, byte[] plainText, byte[] random32, ActorBoxKey key) throws IntegrityException {
          CBCHmacBox aesCipher = new CBCHmacBox(Crypto.createAES128(key.getKeyAES()), Crypto.createSHA256(), key.getMacAES());
          CBCHmacBox kuzCipher = new CBCHmacBox(new KuznechikFastEngine(key.getKeyKuz()), new Streebog256(), key.getMacKuz());
  
          // Calculating padding
          int paddingSize = (plainText.length + 1) % 16;
          byte[] paddedPlainText = new byte[plainText.length + 1 + paddingSize];
          ByteStrings.write(paddedPlainText, 0, plainText, 0, plainText.length);
          paddedPlainText[paddedPlainText.length - 1] = (byte) paddingSize;
          PKCS7Padding padding = new PKCS7Padding();
          padding.padding(paddedPlainText, plainText.length, paddingSize);
  
          byte[] kuzIv = ByteStrings.substring(random32, 0, 16);
          byte[] aesIv = ByteStrings.substring(random32, 16, 16);
          byte[] kuzPackage = ByteStrings.merge(kuzIv, kuzCipher.encryptPackage(header, kuzIv, paddedPlainText));
          return ByteStrings.merge(aesIv, aesCipher.encryptPackage(header, aesIv, kuzPackage));
      }
docs: Closing encrypted box
  
  @param header    plain-text header of a box
  @param plainText plain-text content
  @param random32  32 random bytes
  @param key       Box key
  @return encrypted context
  @throws IntegrityException