modulepackage
4.0.0+incompatible
Repository: https://github.com/goodboycyt/icbc_go.git
Documentation: pkg.go.dev
# README
icbc go lib
封装的功能包括,自动加签,验签,加密,解密 aesutil.go:aes加解密文件 icbc_client_go.go:api请求文件 icbc_uiclient_go.go:ui请求文件 icbcSign.go :签名验签文件 myconst.go:常量文件 rsa.go:rsa相关文件 webUtils.go:请求相关
use mod config
require github.com/goodboycyt/icbc_go v1.4.4
or
go get -u github.com/goodboycyt/icbc_client_go
useage
var icbc IcbcClient
icbc.New("1211111", "ddsad+sadsa+RMWK3Ci+sad+YaeH/Qm/r/Topq3lABw==","RSA","UTF-8","json","MIGfMA0GCSqGSIb3DQEBwIDAQAB","","")
request_b := map[string]interface{}{"serviceUrl":"https://url","method":"POST","isNeedEncrypt":false,"extraParams":""}
request_b["biz_content"] = map[string]interface{}{"corp_no":"123213","trx_acc_date":"2020-12-14"}
resP,err :=icbc.execute(&request_b, "202012241521929252" , "")
if err!=nil {
fmt.printLn(err)
}
var icbc IcbcClientUi
icbc.New("11", "=","RSA","UTF-8","json","MIB","","")
request_b := map[string]interface{}{"serviceUrl":"https://1.1.com.cn/ui/1/ui/1/1/1/V1","method":"POST","isNeedEncrypt":false,"extraParams":""}
request_b["biz_content"] = map[string]interface{}{"121":"12121"}
resP,err :=icbc.BuildPostForm(&request_b, "202012241521929252" , "")
if err!=nil {
fmt.printLn(err)
}
# Functions
AesDecrypt 解密.
AesEncrypt 加密.
*
build form
*/.
build get url
*/.
*
generete string before to sign
*/.
DecryptByAes Aes 解密.
*
get request
*/.
*
post request
*/func DoPost(serviceUrl string,params map[string]interface{},charset string, resStr *string) error{ client := &http.Client{ Transport: &http.Transport{ Dial: func(netw, addr string) (net.Conn, error) { conn, err := net.DialTimeout(netw, addr, time.Second*1) //设置建立连接超时 if err != nil { return nil, err } conn.SetDeadline(time.Now().Add(time.Second * 30)) //设置发送接受数据超时 return conn, nil }, ResponseHeaderTimeout: time.Second * 30, },
} q := url.Values{} for k, v := range params { switch v.(type) { case string: q.Add(k, v.(string)) case int: q.Add(k, strconv.FormatInt(int64(v.(int)), 10)) case int64: q.Add(k, strconv.FormatInt(v.(int64), 10)) case float64: q.Add(k, strconv.FormatFloat(v.(float64), 'f', -1, 64)) case float32: q.Add(k, strconv.FormatFloat(float64(v.(float32)), 'f', -1, 64)) } } req, err := http.NewRequest(http.MethodPost, serviceUrl, strings.NewReader(q.Encode())) if err != nil { return err } // 添加请求头 req.Header.Add("content-type", "application/x-www-form-urlencoded;charset="+charset) req.Header.Add("APIGW-VERSION", "bg-go-v1")
//加入get参数 resp, derr := client.Do(req) if derr != nil { return derr } if resp.StatusCode != 200 { return errors.New("response status code is not valid.
EncryptByAes Aes加密 后 base64 再加.
私钥格式化.
公钥格式化.
No description provided by the author
私钥转换.
公钥转换.
加签.
验签.
签名.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author