Пример #1
0
Файл: aa.go Проект: dhwells/go
func main() {
	hdr := map[string]string{}
	e, _ := armor.Encode(os.Stdout, "RADIX-64", hdr)

	const NBUF = 512
	var buf [NBUF]byte
	var err, erw os.Error
	var nr, nw int
	for {
		switch nr, err = os.Stdin.Read(buf[:]); true {
		case nr < 0:
			fmt.Fprintf(os.Stderr, "error reading from Stdin: %s\n", err.String())
			os.Exit(1)
		case nr == 0:
			break
		case nr > 0:
			if nw, erw = e.Write(buf[0:nr]); nw != nr {
				fmt.Fprintf(os.Stderr, "error writing encoded bytes to Stdout: %s\n", erw.String())
				os.Exit(1)
			}
		}
		if err == os.EOF {
			break
		}
	}
	e.Close()
}
Пример #2
0
func armoredDetachSign(w io.Writer, signer *Entity, message io.Reader, sigType packet.SignatureType) (err error) {
	out, err := armor.Encode(w, SignatureType, nil)
	if err != nil {
		return
	}
	err = detachSign(out, signer, message, sigType)
	if err != nil {
		return
	}
	return out.Close()
}
Пример #3
0
func ArmoredPublicKey(entity *openpgp.Entity) (string, os.Error) {
	var buf bytes.Buffer
	wc, err := armor.Encode(&buf, openpgp.PublicKeyType, nil)
	if err != nil {
		return "", err
	}
	err = entity.PrivateKey.PublicKey.Serialize(wc)
	if err != nil {
		return "", err
	}
	wc.Close()
	return buf.String(), nil
}