They have rights to do this but they super rarely do it.
Except if you are recognized by them as a threat like a terrorist and the like by true or mistaken, they will not touch you and search your electronic devices. Risk exists but not too big.
That's how I see and perceive it, too. I never had real issues when crossing borders, though my sample space isn't that large.
When I had a laptop in my hand luggage, it got x-rayed and I had to "prove" it's not a bomb by showing the security it turns on and "behaves" like a normal laptop. My mobile phone was never touched nor inspected nor did I have to show anything on it.
People supporting Edward Snowden or Julian Assange are likely treated differently, especially when crossing USA or other very USA devoted countries' borders.
We discuss here a topic with premisses set by OP. My assumption here is, you need to cross borders with all your coins you possess.
Yes, I know, we don't carry the coins, we have to carry all details necessary to recover all our private keys that control all our coins. Whatever you do upfront to minimize those needed recovery details, is up to you.If I'm paranoid and don't want to give any hint that I have Bitcoin, I wouldn't carry a hardware wallet with me, even when it's factory reset. I can't assume, no security or border personal doesn't know how the most common hardware wallets look like.
And this here isn't only about digital devices. Anything is valid, be it digital or analog or carved into your wet brain memory. The latter is risky, human memory is a fragile thing, keep this in mind (pun intended).