本文整理汇总了Golang中encoding/base64.NewEncoding函数的典型用法代码### 示例。如果您正苦于以下问题:Golang NewEncoding函数的具体用法?Golang NewEncoding怎么用?Golang NewEncoding使用的例子?那么恭喜您, 这里精选的函数代码### 示例或许可以为您提供帮助。
在下文中一共展示了NewEncoding函数的20个代码### 示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码### 示例。
示例1: Init
func (this *PrePackModule) Init(global_conf *context.GlobalContext) (err error) {
this.click_head = global_conf.Prepack.ClickHeader
this.win_head = global_conf.Prepack.WinHeader
this.common_head = global_conf.Prepack.CommonHeader
utils.DebugLog.Write("Prepack.ClickHeader [%s]", this.click_head)
utils.DebugLog.Write("Prepack.WinHeader [%s]", this.win_head)
base64_code := [64]string{"0Ge5Q6wnuBML3Wg-8s7kAjOr2xohRHif1CczEXDKq_VaUPJdYpy9TSNvIFmbZ4tl", "1RPspa70TiZum_6tKNIFOVJ4o3gBGkdLlvhCnQHWDxEA5cq8fYzj2XU9MwrS-ybe", "2txfHr4BFaqSOTVn_CuYozeygvbcL1RNKs8MkWUPG0JpmXd5l6hDIAjw7i9E-Q3Z", "3c5gtSlVFoEXsehLaMJwI0Rv6U7xmWuzCYABP_TDp-QfdKniNrq2Ob419jHkGZy8", "456tTGIcm3EK7_RQpBA2uezWXjqnHPsi9bV-Zx8vSgkwaMlCoJ1DyfLFr0UYNhdO", "5zDkOUe_q7a2TN-Y3fvrnsCHZxhBIdcESPj8GuWXLgib4QwJo6yVtMF0Kp1mA9Rl", "6bgkOJjx8mPI9Y_hWANypSoFtnDadivQ31crfR0uC-K2qzE4UslMXGBTL5Vw7HeZ", "7zXOg9UZp0sa2vWGJP3TCBYR-6eIfHVnmdKwMrbuSlo8LFNthAkqcDy4QxE5ji1_", "8iMsWOQuApUEhoITJfjbYdLqrcF3m17XwNa_B4lVSC-Deny0KPtG6z2k5gx9vZHR", "9gdocC-fpejPiYnHF7l0XrWUAa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QY4BOPg7et-2", "XYc4wekTRE8ZoxQ9dtiyO-3aAfuIjVsCFh_7Jp20rqm5SHWL1lBbnUNzDKvGPMg6", "YHS9KRLhdqbMtaeX6wG4QNp21sBFrIV_y7DlCzOx80UiumWAnT5-PkgocJEf3jZv", "Z_FmazrYTKXHW-4sSbk86D5VPyfN13gBu9deJE7q2ontjQOGhxwiCclUAMvLp0IR", "_rJb0Up6R2hNDWFAH3LswnYd7zPQo1M8KxyIjBugESqTGZtmleifcVkCX9v5-aO4", "-6mTYvy7KRxCr2elEiWbL5qMoc9G1_3untsdpjwDAzFVhZSgBN0aIOU4QkH8fJXP"}
for i := 0; i < len(base64_code); i++ {
this.coder[i] = base64.NewEncoding(base64_code[i])
}
code_char := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
this.basecoder = base64.NewEncoding(code_char)
this.texttpl, err = template.ParseFiles(global_conf.Template.Texttpl)
utils.DebugLog.Write("get texttpl [%s]", global_conf.Template.Texttpl)
if err != nil || this.texttpl == nil {
utils.FatalLog.Write("load texttpl fail, err[%s]", err.Error())
return
}
this.imgtpl, err = template.ParseFiles(global_conf.Template.Imagetpl)
utils.DebugLog.Write("get imagetpl [%s]", global_conf.Template.Imagetpl)
if err != nil || this.imgtpl == nil {
utils.FatalLog.Write("load imagetpl fail, err[%s]", err.Error())
return
}
this.icontexttpl, err = template.ParseFiles(global_conf.Template.Icontexttpl)
utils.DebugLog.Write("get icontpl [%s]", global_conf.Template.Icontexttpl)
if err != nil || this.icontexttpl == nil {
utils.FatalLog.Write("load icontexttpl fail, err[%s]", err.Error())
return
}
this.texttpl_rec, err = template.ParseFiles(global_conf.Template.Texttplrec)
utils.DebugLog.Write("get texttpl_rec [%s]", global_conf.Template.Texttplrec)
if err != nil || this.texttpl_rec == nil {
utils.FatalLog.Write("load txttpl_rec fail . err[%s]", err.Error())
return
}
this.imgtpl_rec, err = template.ParseFiles(global_conf.Template.Imagetplrec)
utils.DebugLog.Write("get texttpl_rec [%s]", global_conf.Template.Imagetplrec)
if err != nil || this.imgtpl_rec == nil {
utils.FatalLog.Write("load imagetpl_rec fail . err[%s]", err.Error())
return
}
this.icontpl_rec, err = template.ParseFiles(global_conf.Template.Icontplrec)
utils.DebugLog.Write("get icontpl_rec [%s]", global_conf.Template.Icontplrec)
if err != nil || this.icontpl_rec == nil {
utils.FatalLog.Write("load icontpl_rec fail . err[%s]", err.Error())
return
}
/* this.recommendtpl, err = template.ParseFiles(global_conf.Template.Recommendtpl)
if err != nil || this.imgtpl == nil {
return
}*/
return
}
开发者ID:ifzz,项目名称:seller_adptor,代码行数:54,代码来源:prepack.go
示例2: HandshakeOfWS
//for a websocket connection this function funcs as handshaking
//apply websocket protocal to establish a connection
func HandshakeOfWS(conn net.Conn) error {
b := make([]byte, 1024)
a := make([]byte, 1024)
n, err := conn.Read(a)
b = append(b, a[:n]...)
if err != nil {
if err == io.EOF {
} else {
return errors.New("error happen when read from connection!")
}
}
re, err := regexp.Compile("Sec-WebSocket-Key: (.*)\r\n")
if checkErr(err) {
return errors.New("regexp error!")
}
result := re.FindStringSubmatch(string(b))
if result == nil {
return errors.New("not right format!")
}
key_tmp := append([]byte(result[1]), []byte(mask)...)
key_tmp_tmp := sha1.Sum(key_tmp)
encoder := base64.NewEncoding(base64Table)
dst := make([]byte, 1024)
encoder.Encode(dst, key_tmp_tmp[:])
reply := "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: " + string(dst) + "\r\n\r\n"
conn.Write([]byte(reply))
return nil
}
开发者ID:muyizixiu,项目名称:commonOperation,代码行数:32,代码来源:h.go
示例3: SendToEvernote
func SendToEvernote(from, to, subject, body string) error {
hp := strings.Split(EmailSrv, ":")
auth := smtp.PlainAuth("", EmailUsr, EmailPwd, hp[0])
subject = erasebractket(subject)
tmpsubject := subject
subidx := 0
for len(tmpsubject) > 0 {
_, size := utf8.DecodeRuneInString(tmpsubject)
if subidx+size > 70 {
break
}
subidx += size
tmpsubject = tmpsubject[size:]
}
subject = subject[:subidx]
subject = strings.Replace(subject, "@", "", -1)
subject += " @股市"
log.Println("SendToEvernote", from, subject, to)
b64 := base64.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
msg := []byte("To: " + to + "\r\nFrom: " + "xhbot" + "<" + EmailUsr + ">\r\nSubject: " + encodeRFC2047(subject) + "\r\n" + "MIME-Version: 1.0\r\n" + "Content-Type: text/html; charset=UTF-8 \r\nContent-Transfer-Encoding: base64\r\n\r\n" + b64.EncodeToString([]byte(body)))
send_to := strings.Split(to, "|")
err := smtp.SendMail(EmailSrv, auth, EmailUsr, send_to, msg)
return err
}
开发者ID:2qif49lt,项目名称:golang,代码行数:31,代码来源:xueqiuqqnotify.go
示例4: SignPolicy
// SignPolicy return the proper signature and other parameters needed to
// generate a valid Cloudfront Signed URL.
// For canned policies this is: Expires, Signature, Key-Pair-Id
// For custom policies this is: Policy, Signature, Key-Pair-Id
//
// More information:
// http://goo.gl/pvA97e
// Command line equivalent:
// cat policy | openssl sha1 -sign cloudfront-keypair.pem | openssl base64 | tr '+=/' '-_~'
func SignPolicy(privateKey PrivateKey, policy PolicySigner, keyPairID string) (string, error) {
signature, err := policy.signWithPrivateKey(privateKey)
if err != nil {
return "", fmt.Errorf("Cannot sign policy: %v", err)
}
encoding := base64.NewEncoding(encodeCloudFront)
paddingMap := func(r rune) rune {
switch r {
case '=':
return '_'
default:
return r
}
}
switch policy.(type) {
case CannedPolicy:
return fmt.Sprintf("Expires=%d&Signature=%s&Key-Pair-Id=%s",
policy.(CannedPolicy).ExpiresAt.Unix(),
strings.Map(paddingMap, encoding.EncodeToString(signature)),
keyPairID,
), nil
case CustomPolicy:
return fmt.Sprintf("Policy=%s&Signature=%s&Key-Pair-Id=%s",
strings.Map(paddingMap, encoding.EncodeToString([]byte(policy.String()))),
strings.Map(paddingMap, encoding.EncodeToString(signature)),
keyPairID,
), nil
}
return "", nil
}
开发者ID:soundcloud,项目名称:sc-gaws,代码行数:41,代码来源:signature.go
示例5: encodeBytes
func encodeBytes(b []byte) (s string) {
// Note that this encoding is not decodable, as we are using '0' for two different bytes.
// This is much safer for using these as parts of file names.
enc := base64.NewEncoding("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz0")
s = enc.EncodeToString(b)
return
}
开发者ID:rhettg,项目名称:ftl,代码行数:7,代码来源:util.go
最后编辑: kuteng 文档更新时间: 2021-08-23 19:14 作者:kuteng