How to sign another person in without revealing the password on Xbox
Both consoles let you connect with the Smartglass app, allowing you to type from a table or phone, which should hide your password. You should also be able to plug a keyboard into your XB1 (my source for this is the tooltips for the MMO onigiri which literally tells you that you can do this). If you can't do either of those for whatever reason than I would suggest you change your password when going around your friends house, or if you are truly skeptic you can always make a second account, put it on your own xbox and make sure the 'share gold' setting is on if your on xb1 (just incase you want to play online). Then log in with the second account on your friends xbox, although they may be annoyed, or feel like you don't trust them if you do that.
Also for xbox 360 and xbox one you don't need to log in to your account, simply have your friend log in on his xbox and play as a guest, but this will restrict you from earning achievements etc and no progress in online stuff with online games will save to a guest account, but coop saves in offline etc will save to the xbox and your friend will have whatever he does save to his account if playing online excetra.