发送普通红包

@param key
商户KEY
@param wxRedPack
红包内容
@param file
证书文件
@param password
证书密码
@return
968684
@Override
    public NutMap send_redpack(String key, WxPayRedPack wxRedPack, File file, String password) {
        String url = payBase + "/mmpaymkttransfers/sendredpack";
        Map<String, Object> params = Lang.obj2map(wxRedPack);
        return this.postPay(url, key, params, file, password);
    }
569083
public boolean setRxMasterKey(byte[] key) {
		boolean res = false;
		if ((key.length == MASTER_KEY_SIZE_32_BYTES)
				|| (key.length == MASTER_KEY_SIZE_16_BYTES)) {
			rxMasterKey = null;
			rxMasterKey = platform.getUtils().copy(key);
			res = true;
			logDebug("setRxMasterKey "
					+ platform.getUtils().byteToHexString(rxMasterKey));
		} else {
			logError("Wrong length iRxMasterKey: " + key.length);
		}
		return res;
	}
170075
public static boolean isLegalPropertyKey(String key)
  {

    return (key.equals(OutputKeys.CDATA_SECTION_ELEMENTS)
            || key.equals(OutputKeys.DOCTYPE_PUBLIC)
            || key.equals(OutputKeys.DOCTYPE_SYSTEM)
            || key.equals(OutputKeys.ENCODING)
            || key.equals(OutputKeys.INDENT)
            || key.equals(OutputKeys.MEDIA_TYPE)
            || key.equals(OutputKeys.METHOD)
            || key.equals(OutputKeys.OMIT_XML_DECLARATION)
            || key.equals(OutputKeys.STANDALONE)
            || key.equals(OutputKeys.VERSION)
            || (key.length() > 0) 
                  && (key.charAt(0) == '{') 
                  && (key.lastIndexOf('{') == 0)
                  && (key.indexOf('}') > 0)
                  && (key.lastIndexOf('}') == key.indexOf('}')));
  }
153896
public static KeyStore openKeyStore(File storeFile, String storePassword) {
        String lc = storeFile.getName().toLowerCase();
        String type = "JKS";
        String provider = null;
        if (lc.endsWith(".p12") || lc.endsWith(".pfx")) {
            type = "PKCS12";
            provider = BC;
        }

        try {
            KeyStore store;
            if (provider == null) {
                store = KeyStore.getInstance(type);
            } else {
                store = KeyStore.getInstance(type, provider);
            }
            storeFile.getParentFile().mkdirs();
            if (storeFile.exists()) {
                FileInputStream fis = null;
                try {
                    fis = new FileInputStream(storeFile);
                    store.load(fis, storePassword.toCharArray());
                } finally {
                    if (fis != null) {
                        fis.close();
                    }
                }
            } else {
                store.load(null);
            }
            return store;
        } catch (Exception e) {
            throw new RuntimeException("Could not open keystore " + storeFile, e);
        }
    }
706137
private PasswordSource passwordSourceWithPrefix(
            final NodeSSHConnectionInfo nodeAuthentication,
            final String prefix
    ) throws IOException
    {
        if (null != nodeAuthentication.getSudoPasswordStoragePath(prefix)) {
            return new BasicSource(nodeAuthentication.getSudoPasswordStorageData(prefix));
        } else {
            return new BasicSource(nodeAuthentication.getSudoPassword(prefix));
        }
    }
1095878
public Map<ChecksumType, String> calculateJavaScriptHashes(File file) throws WssHashException {
        Map<ChecksumType, String> checksums = new EnumMap<>(ChecksumType.class);
        try {
            long fileLength = file.length();
            if (fileLength >= FILE_MAX_SIZE_THRESHOLD){
                logger.debug("Ignore file {}, ({}): maximum file size  is 2GB", file.getName(), FileUtils.byteCountToDisplaySize(fileLength));
                return checksums;
            }
            checksums = calculateJavaScriptHashes(FileUtils.readFileToByteArray(file));
        } catch (Exception e) {
            throw new WssHashException("Error calculating JavaScript hash: "+ e.getMessage());
        }
        return checksums;
    }
686062
function FileKeyInfo(file) {
  this.file = file

  this.getKeyInfo = function(key, prefix) {
    prefix = prefix || ''
    prefix = prefix ? prefix + ':' : prefix
    return "<" + prefix + "X509Data></" + prefix + "X509Data>"
  }

  this.getKey = function(keyInfo) {
    return fs.readFileSync(this.file)
  }
}
1248702
public static SXSSFWorkbook createSXSSFBook(File excelFile, String password) {
		return toSXSSFBook(createBook(excelFile, password));
	}
652064
private byte[] getEncryptedKey(final String fileName,
                                 final int keyNum) throws PKIException {
    byte[] keys = getKeys(fileName);

    int foundKeys = 0;
    int keyStart = 0;
    for (int i = 0; i <keys.length; i++) {
      if (keys[i] != '\n') {
        continue;
      }

      if (keyNum != foundKeys) {
        keyStart = i + 1;
        foundKeys++;
        continue;
      }

      // At end of our key

      int keyLen = i - keyStart;
      byte[] key = new byte[keyLen];
      System.arraycopy(keys, keyStart, key, 0, keyLen);

      return key;
    }

    throw new PKIException("Invalid key number");
  }
408373
@Override
    public NutMap pay_transfers(String key, WxPayTransfers wxPayTransfers, File file, String password) {
        String url = payBase + "/mmpaymkttransfers/promotion/transfers";
        Map<String, Object> params = Lang.obj2map(wxPayTransfers);
        return this.postPay(url, key, params, file, password);
    }
571388
public static  PrivateKey loadPrivateKey(File file) { 
    	FileInputStream inputStream = null;
    	try {
    		inputStream = new FileInputStream(file);			
    		return loadPrivateKey(inputStream);
		} catch (FileNotFoundException e) {
			throw new RuntimeException("文件不存在");
		}finally {
			try {inputStream.close();} catch (Exception e2) {}
		}
    }
439723
public static byte[] passwordBytes(AbstractConfig config, String key, Charset charset) {
    final Password password = config.getPassword(key);
    return password.value().getBytes(charset);
  }
368407
@Override
    public byte[] get(String key) {
        File f = new File(directory, hash(key));
        FileInputStream fi = null;
        byte[] data = null;
        int read = 0;
        try {
            if (outOfDate(f)) {
                f.delete();
                return null;
            }
            data = new byte[(int) f.length()];
            fi = new FileInputStream(f);
            read = fi.read(data);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (fi != null) {
            try {
                fi.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        if (read == 0) {
            return null;
        }
        return data;
    }
319595
function getXmlElementFromRawIndexes(root, indexInfo) {
  let parentPackage = root;
  for (let j = 0; j < indexInfo.path.length; j++) {
    parentPackage = parentPackage.packagedElement[indexInfo.path[j]];
  }
  return parentPackage.packagedElement[indexInfo.index];
}
1023616
private static byte[] lmHash(String password) throws Exception {
        byte[] oemPassword = password.toUpperCase().getBytes("US-ASCII");
        int length = Math.min(oemPassword.length, 14);
        byte[] keyBytes = new byte[14];
        System.arraycopy(oemPassword, 0, keyBytes, 0, length);
        Key lowKey = createDESKey(keyBytes, 0);
        Key highKey = createDESKey(keyBytes, 7);
        Cipher des = Cipher.getInstance("DES/ECB/NoPadding");
        des.init(Cipher.ENCRYPT_MODE, lowKey);
        byte[] lowHash = des.doFinal(LM_HASH_MAGIC_CONSTANT);
        des.init(Cipher.ENCRYPT_MODE, highKey);
        byte[] highHash = des.doFinal(LM_HASH_MAGIC_CONSTANT);
        byte[] lmHash = new byte[16];
        System.arraycopy(lowHash, 0, lmHash, 0, 8);
        System.arraycopy(highHash, 0, lmHash, 8, 8);
        return lmHash;
    }
808639
@Override
    public NutMap pay_jsapi(String key, WxPayUnifiedOrder wxPayUnifiedOrder) {
        NutMap map = this.pay_unifiedorder(key, wxPayUnifiedOrder);
        NutMap params = NutMap.NEW();
        params.put("appId", wxPayUnifiedOrder.getAppid());
        params.put("timeStamp", String.valueOf((int) (System.currentTimeMillis() / 1000)));
        params.put("nonceStr", R.UU32());
        params.put("package", "prepay_id=" + map.getString("prepay_id"));
        params.put("signType", "MD5");
        String sign = WxPaySign.createSign(key, params);
        params.put("paySign", sign);
        return params;
    }
721277
public static SObject of(String key, File file) {
        if (file.canRead() && file.isFile()) {
            SObject sobj = new FileSObject(key, file);
            String fileName = file.getName();
            sobj.setAttribute(ATTR_FILE_NAME, file.getName());
            String fileExtension = S.fileExtension(fileName);
            MimeType mimeType = MimeType.findByFileExtension(fileExtension);
            String type = null != mimeType ? mimeType.type() : null;
            sobj.setAttribute(ATTR_CONTENT_TYPE, type);
            sobj.setAttribute(ATTR_CONTENT_LENGTH, S.string(file.length()));
            return sobj;
        } else {
            return getInvalidObject(key, new IOException("File is a directory or not readable"));
        }
    }