A few roads up behind my house there is a very exclusive little enclave of millionnaire homes. Not my cup of tea - enormous houses with virtually no gardens. Anyways - one of these particular residences, one which does actually have a fair acreage has a siberian husky (female). Typical of the breed she is highly aggressive to all other dogs and I have been told, a small breed got into her gated territory and shed promptly ripped it to shreds. Anyways - she managed to escape one day and I noticed her wandering about my neck of the woods so I went out and spent about 20 minutes calming her down, talking to her from a distance and eventually she came up to me and rolled on her back and let me rub her tummy. Anways - I took her back to her place, locked her back in and ever since then when I come past (this is for the last two or three years) she howls when I come by and while she is still very aggressive to my dogs, she will always let me put my hands through the fence and if very affectionate and will even lick my face. Couple of months ago one of her neighbours came out and was watching me do this and said 'watch out for that one she is evil' and I laughed and said that we had kind of bonded. He kept watching me, I went to leave and he very tentatively went up to the fence and slowly put his hand in. No shit - she almost bit it off. He just swore at her and walked off.
Anyways - dogs are intelligent and highly interesting creatures and maybe are a very good judge of character - assuming I have a good character that is. But it is common sense to me that if you treat an animal with respect, consistency and affection generally they will trust and accept you. I had numerous encounters with the street mongrels in Thailand, and spent time getting to know them and saw the same thing. But noticed how many presumably smart people have absolutely no idea about animals, even domesticated ones. Sad really.
That's the beauty of dogs, and other pets as well, if you treat them well, they're your most loyal friends.