"You do realize I abstain from killing people all the time, right? I don't need a sword to do that."
The Book: After the dwarves are released from their bags, they demand to hear Bilbo's account of the troll incident. They berate him for trying to pickpocket the trolls, until Gandalf mentions that there ought to be a cave nearby that they should search for. They find it easily, but it is closed off by a large stone door. No amount of pushing, or Gandalf's magic, can open it. Bilbo finds a key that one of the trolls had dropped during their fight, and they use that to open the door. The troll's cave is full of gold, food, and weapons. Two swords catch their eyes, due to their beautiful, jewel encrusted scabbards and hilts. Thorin and Gandalf claim these for themselves, and Bilbo takes a knife. Gandalf notes that the swords were not made by men or trolls, but does not mention their elvish origin. Fili makes the decision to leave, but not before all the dwarves have taken as much food as they could. The dwarves sleep until afternoon, and then bury all the pots of gold in a secret area by the river. A great many spells are placed over the treasure to protect it - the text does not say if it's Gandalf who places the spells or not, but it's safe to assume that he is the only magic user in the Company. Thorin then asks Gandalf where he'd gone off to: the conversation plays out almost exactly as it does in the movie, only Thorin gets annoyed at Gandalf's mysterious answer and asks him to speak more clearly. Gandalf mentions that he'd visited Rivendell, and says that they will be going there in a few days time.
What difference does it make? The contents of the troll's cave is, broadly speaking, the same in both film and movie. The food in the troll's cave is not present in the movie, due to the fact that the dwarves in the movie are not suffering from dwindling rations. The gold and weapons are still prevalent. Orcrist and Glamdring are in simple leather sheathes in the movie, instead of the ornate, jeweled works of art described in the novel. Bilbo's role in opening the door is taken away entirely, and Gandalf's conversation to the hobbit about mercy is an invention of the movie. These both change the characterization of Bilbo Baggins.
My Opinion: I'm okay with the decision to remove the stone door, and consequently, the key that Bilbo finds. It's weird to think of the three stupid trolls digging out some hole in the ground, and then magically erecting a door that even a wizard couldn't open. It was also necessary that their shelter be somewhat temporary in the movie; it is an important plot point that trolls are unusual this far south, and giving them a permanent home with a sealed door would undermine that. I'll talk a little more about this plot point when I discuss the White Council.
I like that Gandalf gives Bilbo the elvish knife, but I disagree with the decision to have him talk to Bilbo about mercy like he does. It's a weird sentiment to share with somebody who doesn't even want to carry a weapon: "It's better to NOT kill." Why give him a sword if you're going to encourage him not to use it? If he seems hesitant to own and use a weapon, wouldn't you instead want say something that may inspire bravery or confidence? I get that it foreshadows Bilbo's encounter with Gollum, but it doesn't make a lot of sense outside of that context. Furthermore, it somewhat undermines Bilbo's decision to spare Gollum. His gentle nature and sense of morality should have been sufficient, not a lecture he remembers from earlier.