Skip to content

Instantly share code, notes, and snippets.

View longbill's full-sized avatar
🏠
Working from home

Chunlong longbill

🏠
Working from home
View GitHub Profile
@longbill
longbill / xml2array.php
Created March 3, 2012 07:05
One line xml to array in php
<?php
function xml2array($x)
{
return json_decode(json_encode(simplexml_load_string($x)),true);
}
?>
@longbill
longbill / wxcrypto.js
Last active March 4, 2022 08:43
微信公众号消息加密解密nodejs模块
const crypto = require('crypto');
const debug = require('debug')('wxcrypto');
/**
* 微信公众号消息加密解密,支持 node > 8.0
*
* var WXCrypto = require('this module');
* var wx = new WXCrypto(token, aesKey, appid);
*
* var [err, encryptedXML] = wx.encrypt(xml, timestamp, nonce);
@longbill
longbill / socks5.js
Last active May 15, 2024 08:04
Socks5 proxy server in pure javascript
const net = require('net')
net.createServer(client => {
client.once('data', data => {
client.write(Buffer.from([5, 0]));
client.once('data', data => {
data = [...data];
let ver = data.shift();
let cmd = data.shift(); //1: connect, 2: bind, 3: udp
let rsv = data.shift();