• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang base64.Encoding类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中encoding/base64.Encoding的典型用法代码示例。如果您正苦于以下问题:Golang Encoding类的具体用法?Golang Encoding怎么用?Golang Encoding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Encoding类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: SignEncoded

// SignBytes, but will base64 encode based on the specified encoder.
func (self *Signer) SignEncoded(h crypto.Hash, s string, e *base64.Encoding) (out []byte, err error) {
	ob, err := self.SignBytes(h, bytes.NewBufferString(s).Bytes())
	if err == nil {
		out = make([]byte, e.EncodedLen(len(ob)))
		e.Encode(out, ob)
	}
	return
}
开发者ID:ncw,项目名称:GoAWS,代码行数:9,代码来源:signer.go


示例2: Encode

// Encode makes it a bit easier to deal with base 64 encoding, see
// example code below.
func Encode(encBuf, bin []byte, e64 *base64.Encoding) []byte {
	maxEncLen := e64.EncodedLen(len(bin))
	if encBuf == nil || len(encBuf) < maxEncLen {
		encBuf = make([]byte, maxEncLen)
	}
	e64.Encode(encBuf, bin)
	return encBuf[0:]
}
开发者ID:dvln,项目名称:util,代码行数:10,代码来源:base64.go


示例3: SignEncoded

// SignBytes, but will base64 encode based on the specified encoder.
func (p *signer) SignEncoded(h crypto.Hash, s string, enc *base64.Encoding) (signature []byte, err os.Error) {
	buf, err := p.SignBytes(h, bytes.NewBufferString(s).Bytes())
	if err == nil {
		signature = make([]byte, enc.EncodedLen(len(buf)))
		enc.Encode(signature, buf)
	}
	return
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:9,代码来源:signer.go


示例4: Sign64

// Sign a string with a specified signer and base64 encoding
func Sign64(s Signer, e *base64.Encoding, sts []byte) (out []byte, err os.Error) {
	sig, err := s.Sign(sts)
	if err != nil {
		return
	}
	out = make([]byte, e.EncodedLen(len(sig)))
	e.Encode(out, sig)
	return
}
开发者ID:welterde,项目名称:GoCryptools,代码行数:10,代码来源:signer.go


示例5: Decode

// Decode makes it a bit easier to deal with base 64 decoding, see
// example code below.
func Decode(decBuf, enc []byte, e64 *base64.Encoding) []byte {
	maxDecLen := e64.DecodedLen(len(enc))
	if decBuf == nil || len(decBuf) < maxDecLen {
		decBuf = make([]byte, maxDecLen)
	}
	n, err := e64.Decode(decBuf, enc)
	_ = err
	return decBuf[0:n]
}
开发者ID:dvln,项目名称:util,代码行数:11,代码来源:base64.go


示例6: Sign64Mech

func Sign64Mech(mech string, s SignerMultiMech, e *base64.Encoding, sts []byte) (out []byte, err os.Error) {
	sig, err := s.Sign(mech, sts)
	if err != nil {
		return
	}
	out = make([]byte, e.EncodedLen(len(sig)))
	e.Encode(out, sig)
	return
}
开发者ID:abneptis,项目名称:GoCryptools,代码行数:9,代码来源:signermm.go


示例7: Base64Decode

func Base64Decode(enc *base64.Encoding, src []byte) ([]byte, error) {
	l := len(src)
	dst := make([]byte, enc.DecodedLen(l))
	l, err := enc.Decode(dst, src)
	if err != nil {
		return nil, err
	}

	return dst[:l], nil
}
开发者ID:huangjiasingle,项目名称:gohper,代码行数:10,代码来源:encoding.go


示例8: Sign64

// Sign a string with a specified signer and base64 encoding
func Sign64(s Signer, e *base64.Encoding,
	ss Signable) (out []byte, err os.Error) {

	sig, err := s.Sign(ss)
	if err != nil {
		return
	}
	bb := sig.SignatureBytes()
	out = make([]byte, e.EncodedLen(len(bb)))
	e.Encode(out, bb)
	return
}
开发者ID:abneptis,项目名称:GoCryptools,代码行数:13,代码来源:funcs.go


示例9: dns

func dns(username string, password string, domain string, ip string) string {
	//base64
	Authorization := username + ":" + password
	encodeStd := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
	var en *base64.Encoding = base64.NewEncoding(encodeStd)
	var buf *bytes.Buffer = bytes.NewBufferString(Authorization)
	enS := en.EncodeToString(buf.Bytes())

	//http request and header
	url := fmt.Sprintf("http://ddns.oray.com/ph/update?hostname=%s&myip=%s", domain, ip)
	requ, _ := http.NewRequest("GET", url, nil)
	requ.Header.Add("Authorization", "Basic "+enS)
	requ.Header.Add("User-Agent", "FUCKALL")

	client := new(http.Client)
	resp, _ := client.Do(requ)
	defer resp.Body.Close()

	body, _ := ioutil.ReadAll(resp.Body)
	buf = bytes.NewBuffer(body)
	bufS := buf.String()
	return bufS
}
开发者ID:fengzai,项目名称:snippet,代码行数:23,代码来源:dynamicDns.go


示例10: search

func (s *Base64Finder) search(searchFor []byte, url bool) bool {

	var encoding *base64.Encoding

	if url {
		encoding = base64.URLEncoding
	} else {
		encoding = base64.StdEncoding
	}

	i := 0
	for i >= 0 {
		var msg string
		msg, i = s.findOne(i)
		if len(msg) > 0 {
			buf, err := encoding.DecodeString(msg)
			if err == nil && FastByteArrayEq(searchFor, buf) {
				return true
			}
		}
	}

	return false
}
开发者ID:mark-adams,项目名称:client,代码行数:24,代码来源:base64_finder.go


示例11: Base64Encode

func Base64Encode(enc *base64.Encoding, src []byte) []byte {
	l := len(src)
	dst := make([]byte, enc.EncodedLen(l))
	enc.Encode(dst, src)
	return dst
}
开发者ID:huangjiasingle,项目名称:gohper,代码行数:6,代码来源:encoding.go


示例12: SendMail

func (this *Sender) SendMail() (e error) {
	var (
		deadline time.Duration = 5 * time.Second
		encoding *base64.Encoding
		buf      []byte = make([]byte, 512)
		r        int
	)
	encoding = base64.NewEncoding(tb)
	conn, e := net.Dial("tcp", this.Host)
	if e != nil {
		return
	}
	defer conn.Close()

	conn.SetDeadline(time.Now().Add(deadline))
	r, e = conn.Read(buf)
	if e != nil {
		return
	}
	fmt.Println(string(buf[:r-1]))

	conn.Write([]byte("EHLO Juxuny\r\n"))
	conn.SetDeadline(time.Now().Add(deadline))
	r, e = conn.Read(buf)
	if e != nil {
		return
	}
	fmt.Println(string(buf[:r-1]))

	conn.Write([]byte("AUTH LOGIN\r\n"))
	conn.SetDeadline(time.Now().Add(deadline))
	r, e = conn.Read(buf)
	if e != nil {
		return
	}
	fmt.Println(string(buf[:r-1]))

	conn.Write([]byte(encoding.EncodeToString([]byte(this.UserName)) + "\r\n"))
	conn.SetDeadline(time.Now().Add(deadline))
	r, e = conn.Read(buf)
	if e != nil {
		return
	}
	fmt.Println(string(buf[:r-1]))

	conn.Write([]byte(encoding.EncodeToString([]byte(this.Password)) + "\r\n"))
	conn.SetDeadline(time.Now().Add(deadline))
	r, e = conn.Read(buf)
	if e != nil {
		return
	}
	fmt.Println(string(buf[:r-1]))

	conn.Write([]byte("MAIL FROM: <" + this.From + ">" + "\r\n"))
	conn.SetDeadline(time.Now().Add(deadline))
	r, e = conn.Read(buf)
	if e != nil {
		return
	}
	fmt.Println(string(buf[:r-1]))

	conn.Write([]byte("RCPT TO <" + this.To + ">\r\n"))
	conn.SetDeadline(time.Now().Add(deadline))
	r, e = conn.Read(buf)
	if e != nil {
		return
	}
	fmt.Println(string(buf[:r-1]))

	conn.Write([]byte("DATA\r\n"))
	conn.Write([]byte("\r\n"))
	conn.Write([]byte("Message-ID: <" + this.From + ">\r\n"))
	conn.Write([]byte("X-Mailer: <MMail 1.0>"))
	conn.Write([]byte("MIME-Version: 1.0"))
	conn.Write([]byte("Content-Type: text/plain"))
	conn.Write([]byte("From: <" + this.From + ">\r\n"))
	conn.Write([]byte("To: <" + this.To + ">\r\n"))
	conn.Write([]byte("Subject: " + this.Subject + "\r\n"))
	conn.Write([]byte("\r\n"))
	conn.Write([]byte(this.Text))
	conn.Write([]byte("\r\n.\r\n"))

	time.Sleep(5e9)
	conn.Write([]byte("QUIT\r\n"))
	conn.SetDeadline(time.Now().Add(deadline))
	r, e = conn.Read(buf)
	if e != nil {
		fmt.Println(e)
		return
	}
	fmt.Println(string(buf[:r-1]))

	return
}
开发者ID:yanue,项目名称:go-webmail,代码行数:94,代码来源:smtp.go



注:本文中的encoding/base64.Encoding类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang binary.PutUvarint函数代码示例发布时间:2022-05-24
下一篇:
Golang base64.NewEncoding函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap