コード例 #1
0
ファイル: enc.go プロジェクト: postfix/enc
func ecTransmitMessage(conn net.Conn, pub *ecies.PublicKey) {
	var msg = make([]byte, 0)

	for {
		var buf = make([]byte, BufSize)
		n, err := os.Stdin.Read(buf)
		if err != nil {
			if err == io.EOF {
				break
			}
			fmt.Fprintln(os.Stderr, err.Error())
			return
		}
		msg = append(msg, buf[:n]...)
	}
	ct, err := ecies.Encrypt(rand.Reader, pub, msg, nil, nil)
	if err != nil {
		fmt.Fprintln(os.Stderr, err.Error())
		return
	}
	conn.Write(ct)
}
コード例 #2
0
ファイル: hybrid.go プロジェクト: jonathanmarvens/gocrypto
func Encrypt(pub *ecies.PublicKey, pt []byte) ([]byte, error) {
	return ecies.Encrypt(rand.Reader, pub, pt, nil, nil)
}