I believe hamsters are really quite intelligent.
It's something I've noticed with the hammies I have now, the development of trust and knowing who it is they are associating with.
My little Finley is an incredibly shy little ham, probably the most shy hamster I've owned. I am the only person he will allow to pick him up, and he becomes very relaxed when I handle him. When I put my hand into his box, I let him sniff me before I pick him up, and he immediately relaxes when he knows it's me. He had learnt to trust my mum, because she gives him treats when I'm not at home, so although he won't allow her to pick him up, he associates her with treats and is fine with her. Any other person who has tried to touch him has been bitten, because he doesn't know them and he panics.
He has actually taught me some things, and now I apply how I treat him to the untame baby hamsters I have to deal with at work.
I believe he sees me not only as a source of treats, but a source of security and friendship. For such a flighty little creature, he loves his cuddles in bed with mummy.
They definitely have the ability to distinguish people, and respond to different people in accordance. They know people for reasons other than 'they get food when this person appears'.
Todd is another matter. I think he is very clever, and I have a very close bond with this little man. He responds to several words, including his name, and when he's out having free range of my room, he will come back to me if I call. Even more interestingly, if I sit on the floor whilst he's running around, every now and again he'll come back to me to 'check on me' so to speak. :L He'll come dashing out and climb up onto my knee, give himself a quick groom, lick my hand (yes, I need grooming too xD) and then he'll dash off again. He does this every 3 - 5 mins or so.
He loves his cuddles with me, and like Fin I think he enjoys a sense of security and sociability when I hold him. He snuggles into my hand and when I stroke his back he'll lick my fingers. We have lovely little cuddles. ^^
I'm going to see what I can teach Todd, because he's so responsive to voice and touch, I think I could teach him quite a lot. He also knows if I scratch the carpet whilst he's running around, I want him to come back to my hand, in case he hasn't heard my voice.