本文整理匯總了Golang中encoding/base64.Encoding.Encode方法的典型用法代碼示例。如果您正苦於以下問題:Golang Encoding.Encode方法的具體用法?Golang Encoding.Encode怎麽用?Golang Encoding.Encode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類encoding/base64.Encoding
的用法示例。
在下文中一共展示了Encoding.Encode方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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
}
示例2: 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
}
示例3: 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:]
}
示例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
}
示例5: 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
}
示例6: 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
}
示例7: Base64Encode
func Base64Encode(enc *base64.Encoding, src []byte) []byte {
l := len(src)
dst := make([]byte, enc.EncodedLen(l))
enc.Encode(dst, src)
return dst
}