Assume I want to exchange a hash value between two machines for some purpose, how do I prevent Man-in-middle from capturing it without encrypting the hash value itself?
You can create an ssh tunnel between the two participating machines and can send the unencrypted data.
Say you are using linux.
1) First create a ssh server on the machine receiving the data you can use openssh to create it.Install openssh-server and then add port to listen in /etc/ssh/sshd_config
sudo apt-get install openssh-server
2) Now after the server is created you can access it from other machine using ssh clients available like putty or ssh command line.
ssh username@ip -p port
3) Now you can copy file using scp.
scp -P port file username@ip:new_file