code: private String wrap(Key key, String wrapAlgorithm) {
  
          try {
  
              Cipher cipher = Cipher.getInstance(wrapAlgorithm);
              cipher.init(Cipher.WRAP_MODE, wrapKey);
              byte[] wrappedKey = cipher.wrap(key);
              return ByteArray.toBase64(wrappedKey);
  
          } catch (NoSuchAlgorithmException e) {
              if (SecurityProvider.addProvider()) {
                  return wrap(key, wrapAlgorithm);
              } else {
                  throw new IllegalStateException("Algorithm unavailable: " + wrapAlgorithm, e);
              }
          } catch (NoSuchPaddingException e) {
              throw new IllegalStateException("Padding unavailable: " + wrapAlgorithm, e);
          } catch (InvalidKeyException e) {
              throw new IllegalArgumentException("Invalid key for " + wrapAlgorithm, e);
          } catch (IllegalBlockSizeException e) {
              throw new IllegalStateException("Error in block size for algorithm " + wrapAlgorithm, e);
          }
      }
docs: Wraps the given {@link Key} using the given wrap algorithm.
  
  @param key           The {@link Key} to be wrapped. This can be a secret
  (symmetric) key or a private (asymmetric) key.
  @param wrapAlgorithm The algorithm to use to wrap the key. This has to be different
  for a {@link SecretKey} than for a {@link PrivateKey}.
  @return A String representation (base64-encoded) of the wrapped
  {@link Key}.