Skip to content

Instantly share code, notes, and snippets.

@shautzin
shautzin / AES.go
Created March 24, 2017 01:59
AES/CBC/PKCS5Padding implementation by Golang
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"fmt"
)
func main() {
@shautzin
shautzin / http.go
Created March 17, 2017 01:55
Http Get&Post Request by Golang
type Resp struct {
status string // http status
response []byte // http response
err error // err
}
func get(u string, param map[string]string) *Resp {
queryValues := url.Values{}
for k, v := range param {
queryValues[k] = []string{v}
package com.liuxey.uitl;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.security.MessageDigest;
@shautzin
shautzin / Generic_DB_Key
Created May 22, 2014 06:58
JdbcTemplate generic Mysql Primary key value by update method
/**
* 插入一条记录
*
* @param columns
* @param values
* @return
*/
public long insert(String[] columns, Object[] values) {
String sql = insertSql(columns);
KeyHolder keyHolder = new GeneratedKeyHolder();
@shautzin
shautzin / ZipUtil.java
Created April 15, 2014 03:00
Java ZipUtil
import java.io.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* Created by ShaoJin on 2014/4/15 0015.
*/
public class ZipUtil {
@shautzin
shautzin / HttpClientRequestFile
Created April 11, 2014 10:25
HttpClientRequestFile
/**
* 下载文件
* @param httpClient
* @param url
*/
public boolean httpGetFile(CloseableHttpClient httpClient, String url, java.io.File file) throws IOException {
HttpGet httpGet = createHttpGet(url);
httpGet.setHeader(HttpHeaders.USER_AGENT, Constant.USER_AGENT);
CloseableHttpResponse response = httpClient.execute(httpGet);
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.util.Map;
/**
* Anti XSS RequestWraper
*
* <p>
*
* Usage: write {chain.doFilter(new XssHttpServletRequestWrapper((HttpServletRequest) request), response);}