All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.chanjar.weixin.open.util.WxOpenCryptUtil Maven / Gradle / Ivy

The newest version!
package me.chanjar.weixin.open.util;

import com.google.common.base.CharMatcher;
import com.google.common.io.BaseEncoding;
import me.chanjar.weixin.open.api.WxOpenConfigStorage;
import org.apache.commons.lang3.StringUtils;

import java.util.Base64;

/**
 * @author 007
 */
public class WxOpenCryptUtil extends me.chanjar.weixin.common.util.crypto.WxCryptUtil {
  /**
   * 构造函数
   *
   * @param wxOpenConfigStorage
   */
  public WxOpenCryptUtil(WxOpenConfigStorage wxOpenConfigStorage) {
    /*
     * @param token          公众平台上,开发者设置的token
     * @param encodingAesKey 公众平台上,开发者设置的EncodingAESKey
     * @param appId          公众平台appid
     */
    String encodingAesKey = wxOpenConfigStorage.getComponentAesKey();
    String token = wxOpenConfigStorage.getComponentToken();
    String appId = wxOpenConfigStorage.getComponentAppId();

    this.token = token;
    this.appidOrCorpid = appId;
    this.aesKey = Base64.getDecoder().decode(StringUtils.remove(encodingAesKey, " "));
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy