本文整理汇总了Java中com.qq.weixin.mp.aes.WXBizMsgCrypt类的典型用法代码示例。如果您正苦于以下问题:Java WXBizMsgCrypt类的具体用法?Java WXBizMsgCrypt怎么用?Java WXBizMsgCrypt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WXBizMsgCrypt类属于com.qq.weixin.mp.aes包,在下文中一共展示了WXBizMsgCrypt类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: contextInitialized
import com.qq.weixin.mp.aes.WXBizMsgCrypt; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
MyazureConstants.MYAZURE_APP_ID = MYAZURE_APP_ID;
MyazureConstants.MYAZURE_APP_SECRET = MYAZURE_APP_SECRET;
MyazureConstants.MYAZURE_ENCODE_TOKEN = MYAZURE_ENCODE_TOKEN;
MyazureConstants.MYAZURE_ENCODE_KEY = MYAZURE_ENCODE_KEY;
MyazureConstants.MYAZURE_APP_URL = MYAZURE_APP_URL;
MyazureConstants.MYAZURE_SERVER_ID = MYAZURE_SERVER_ID;
API.defaultMode(API.MODE_POPULAR);
MyazureConstants.MYAZURE_COMPONENT_ACCESS_TOKEN = redisTemplate.opsForValue().get(WeixinConstans.COMPONENT_ACCESS_TOKEN_KEY);
LocalHttpClient.init(1000, 100);
try {
MyazureConstants.MYAZUZRE_WXBIZMSGCRYPT = new WXBizMsgCrypt(MyazureConstants.MYAZURE_ENCODE_TOKEN, MyazureConstants.MYAZURE_ENCODE_KEY,
MyazureConstants.MYAZURE_APP_ID);
} catch (AesException e) {
LOG.error(e.getMessage());
}
if (MyazureConstants.MYAZURE_APP_ID == null || MyazureConstants.MYAZURE_APP_SECRET == null || MyazureConstants.MYAZURE_ENCODE_TOKEN == null
|| MyazureConstants.MYAZURE_ENCODE_KEY == null) {
LOG.error("System Going Down|!!!!!!!!!!!!!!!!!!NULL!!!ID!!!!SECRET!!!!TOKEN!!!!!!KEY!!!!!");
}
LOG.debug("Myazure Weixin MYAZURE_COMPONENT_ACCESS_TOKEN:"+MyazureConstants.MYAZURE_COMPONENT_ACCESS_TOKEN);
}
开发者ID:Myazure,项目名称:weixin_component,代码行数:24,代码来源:SystemInitListener.java
示例2: MessageUtils
import com.qq.weixin.mp.aes.WXBizMsgCrypt; //导入依赖的package包/类
private MessageUtils(String token, String encodingAesKey, String appID) {
try {
this.enDeCrypter = new WXBizMsgCrypt(token, encodingAesKey, appID);
} catch (AesException e) {
LOGGER.error("init enDecrypter", e);
}
}
开发者ID:oopschen,项目名称:sdk-weixin,代码行数:8,代码来源:MessageUtils.java
示例3: main
import com.qq.weixin.mp.aes.WXBizMsgCrypt; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
//
// 第三方回复公众平台
//
// 需要加密的明文
String encodingAesKey = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG";
String token = "pamtest";
String timestamp = "1409304348";
String nonce = "xxxxxx";
String appId = "wxb11529c136998cb6";
String replyMsg = " 中文<xml><ToUserName><![CDATA[oia2TjjewbmiOUlr6X-1crbLOvLw]]></ToUserName><FromUserName><![CDATA[gh_7f083739789a]]></FromUserName><CreateTime>1407743423</CreateTime><MsgType><![CDATA[video]]></MsgType><Video><MediaId><![CDATA[eYJ1MbwPRJtOvIEabaxHs7TX2D-HV71s79GUxqdUkjm6Gs2Ed1KF3ulAOA9H1xG0]]></MediaId><Title><![CDATA[testCallBackReplyVideo]]></Title><Description><![CDATA[testCallBackReplyVideo]]></Description></Video></xml>";
WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, appId);
String mingwen = pc.encryptMsg(replyMsg, timestamp, nonce);
System.out.println("加密后: " + mingwen);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
StringReader sr = new StringReader(mingwen);
InputSource is = new InputSource(sr);
Document document = db.parse(is);
Element root = document.getDocumentElement();
NodeList nodelist1 = root.getElementsByTagName("Encrypt");
NodeList nodelist2 = root.getElementsByTagName("MsgSignature");
String encrypt = nodelist1.item(0).getNodeValue();
String msgSignature = nodelist2.item(0).getNodeValue();
String format = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><Encrypt><![CDATA[%1$s]]></Encrypt></xml>";
String fromXML = String.format(format, encrypt);
//
// 公众平台发送消息给第三方,第三方处理
//
// 第三方收到公众号平台发送的消息
String result2 = pc.decryptMsg(msgSignature, timestamp, nonce, fromXML);
System.out.println("解密后明文: " + result2);
//pc.verifyUrl(null, null, null, null);
}
开发者ID:hanwwh,项目名称:xqres,代码行数:45,代码来源:Program.java
注:本文中的com.qq.weixin.mp.aes.WXBizMsgCrypt类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论