本文整理匯總了Golang中github.com/octokey/octokey-go/buffer.Buffer類的典型用法代碼示例。如果您正苦於以下問題:Golang Buffer類的具體用法?Golang Buffer怎麽用?Golang Buffer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Buffer類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: String
// Format gives you the partial key in the canonical representation including
// ----BEGIN/END headers.
func (k *PartialKey) String() string {
b := new(buffer.Buffer)
k.WriteBuffer(b)
if b.Error != nil {
panic(errors.New("invalid partial key: " + b.Error.Error()))
}
return HEADER + "\n" + lineWrap(b.String(), 64) + FOOTER + "\n"
}
示例2: String
// String produces the line-wrapped base-64 version of the challenge,
// suitable for being passed to NewSignRequest()
func (request *SignRequest) String() string {
b := new(buffer.Buffer)
request.WriteBuffer(b)
if b.Error != nil {
panic(errors.New("invalid sign request: " + b.Error.Error()))
}
return SIGN_REQUEST_HEADER + "\n" + lineWrap(b.String(), 64) + SIGN_REQUEST_FOOTER + "\n"
}
示例3: String
// String returns the public key in the same format as used by ssh
func (p *PublicKey) String() string {
b := new(buffer.Buffer)
p.WriteBuffer(b)
if b.Error != nil {
panic(errors.New("invalid public key: " + b.Error.Error()))
}
return PUBLIC_KEY_TYPE + " " + b.String() + "\n"
}
示例4: ReadBuffer
// ReadBuffer reads the public key from a buffer.
func (p *PublicKey) ReadBuffer(b *buffer.Buffer) error {
t := b.ScanString()
e := b.ScanMPInt()
n := b.ScanMPInt()
if t != PUBLIC_KEY_TYPE {
return ErrPublicKeyFormat
}
if e.Cmp(big.NewInt(EXPONENT)) != 0 {
return ErrPublicKeyFormat
}
p.E = EXPONENT
p.N = n
return nil
}
示例5: ReadBuffer
// ReadBuffer reads a SignRequest from a buffer.
func (request *SignRequest) ReadBuffer(b *buffer.Buffer) error {
publicKey := new(PublicKey)
err := publicKey.ReadBuffer(b)
if err != nil {
return err
}
msg := b.ScanMPInt()
if msg.Cmp(publicKey.N) >= 0 {
return errors.New("cannot sign message > N")
}
request.Key = publicKey
request.M = msg
return nil
}
示例6: WriteBuffer
// WriteBuffer writes the PartialKey to a buffer
func (k *PartialKey) WriteBuffer(b *buffer.Buffer) {
b.AddString(KEY_TYPE)
b.AddMPInt(big.NewInt(int64(k.E)))
b.AddMPInt(k.N)
b.AddMPInt(k.D)
}
示例7: WriteBuffer
// WriteBuffer writes the public key to a buffer.
func (p *PublicKey) WriteBuffer(b *buffer.Buffer) {
b.AddString(PUBLIC_KEY_TYPE)
b.AddMPInt(big.NewInt(int64(p.E)))
b.AddMPInt(p.N)
}
示例8: WriteBuffer
func (request *SignRequest) WriteBuffer(b *buffer.Buffer) {
request.Key.WriteBuffer(b)
b.AddMPInt(request.M)
}
示例9: unsignedBuffer
func (a *AuthRequest) unsignedBuffer() *buffer.Buffer {
b := buffer.Buffer{}
b.AddBuffer(a.ChallengeBuffer)
b.AddString(a.RequestUrl)
b.AddString(a.Username)
b.AddString(a.ServiceName)
b.AddString(a.AuthMethod)
b.AddString(a.SigningAlgorithm)
// b.AddVarBytes(publicKeyBytes(a.PublicKey))
panic("todo")
return &b
}