code: public void encrypt(final String userName, final byte[] password, final MessageEncryption msgEncryption) {
          setUserName(null);
          setPassword(null);
          setNonce(null);
          setCreated(null);
  
          byte[] nonce = null;
  
          switch (msgEncryption) {
              case NONE: {
                  nonce = WSSecurityUtil.generateNonce(32);
  
                  break;
              }
  
              case JSON: {
                  final ByteArrayOutputStream os = Objectory.createByteArrayOutputStream();
  
                  try {
                      HTTP.jsonParser.serialize(os, this, jsc);
                      nonce = os.toByteArray();
                  } finally {
                      Objectory.recycle(os);
                  }
  
                  break;
              }
  
              case KRYO: {
                  final ByteArrayOutputStream os = Objectory.createByteArrayOutputStream();
  
                  try {
                      HTTP.kryoParser.serialize(os, this);
                      nonce = os.toByteArray();
                  } finally {
                      Objectory.recycle(os);
                  }
  
                  break;
              }
  
              default:
                  throw new IllegalArgumentException("Unsupported Message encryption way: " + msgEncryption);
          }
  
          final String created = String.valueOf(System.currentTimeMillis());
  
          setUserName(userName);
          setPassword(WSSecurityUtil.doPasswordDigest(nonce, created.getBytes(Charsets.UTF_8), password));
          setNonce(N.base64Encode(nonce));
          setCreated(created);
      }
docs: Encrypt this request with specified userName and password.
  
  @param userName
  @param password
  @param msgEncryption