Not a word, but a longish phrase.
Don't let her/his rough exterior fool you; underneath that grumpy disposition beats a heart of gold
TV tropes has a page dedicated to Jerk with a Heart of Gold, which is a much shorter phrase.
A person you would expect to be a big Jerkass has some redeeming qualities behind their tough demeanor. Occasionally, they'll try to make it a Hidden Heart of Gold.
And for the latter, TV Tropes describes the character thus
Hidden Heart of Gold
Bob is a total Jerkass. He's the type to knock a guy down and kick him when he tries to get up, the type who'll bed a girl then toss her aside. Just ask anyone. […] So why is a nice girl like Alice with him? Well Alice knows of a different side, one where he's always nice to her when they're together; she's seen him do a few good deeds when he didn't know she was watching. Like reading to orphans, making donations to charity, or just plain helping others. Thing is, eventually Alice is going to confront him about his true self, call him out for his crime of... kindness.