Пример #1
0
func (c Connection) SetPassword(password string) {
	passwordC := C.CString(password)
	defer C.free(unsafe.Pointer(passwordC))

	C.pn_connection_set_password(c.pn, passwordC)
}
Пример #2
0
// SetPassword takes []byte not string because it is impossible to erase a string
// from memory reliably. Proton will not keep the password in memory longer than
// needed, the caller should overwrite their copy on return.
//
// The password must not contain embedded nul characters, a trailing nul is ignored.
func (c Connection) SetPassword(password []byte) {
	if len(password) == 0 || password[len(password)-1] != 0 {
		password = append(password, 0) // Proton requires a terminating null.
	}
	C.pn_connection_set_password(c.pn, (*C.char)(unsafe.Pointer(&password[0])))
}