Customs/border patrol

After reading a few articles, it has come to my attention that customs have the right to search through devices such as phones, tablets, laptops etc. when traveling internationally, and refusal to hand over passwords can lead to prosecution, detainment and confiscation of devices.

How does one go about protecting sensitive information while traveling?

Will wiping devices beforehand draw attention if you are chosen for a ‘random’ screening?

Also, does anyone know if it is a physical search, or a data rip for digital forensics?