import "encoding/pem"
Privacy Enhanced Mailを起源とするPEMデータエンコーディングを実装しています。今現在、PEMエンコードが一般的に使われているのはTLSキーと証明書です。RFC 1421を参照ください。
パッケージファイル
pem.go
Encode関数
func Encode(out io.Writer, b *Block) (err os.Error)
EncodeToMemory関数
func EncodeToMemory(b *Block) []byte
Block型
Blockは、PEMエンコーディングされた構造を表します。
PEMエンコードの形式です。
-----BEGIN Type----- Headers base64-encoded Bytes -----END Type-----
Headersには、キー:値の行が並びます。空の場合もあり得ます。
type Block struct {
Type string // The type, taken from the preamble (i.e. "RSA PRIVATE KEY").
Headers map[string]string // Optional headers.
Bytes []byte // The decoded bytes of the contents. Typically a DER encoded ASN.1 structure.
}
Decode関数
func Decode(data []byte) (p *Block, rest []byte)
Decodeは、dataから次のPEM形式のブロック(証明書、秘密鍵等)を検索し、ブロックとdataの残りを返します。PEMデータが見つからないときはpはnil、restはdataとなります。
Trackback URL
Comments