Ashleigh Brykaliuk, Cassidy Carels, Karly Heffernan and Eden Murray scored for Canada and netminder Jessica Dodds made 10 saves for the victory.
"We didn't have a lot of success early but the great thing is the girls just stuck with the game plan and they kept working at it," said Canadian coach Jim Fetter. "We were able to create a little bit more offence in the third."
Brykaliuk opened the scoring late in the first period at the Vierumaki Areena but Tifani Horvath tied the game midway through the second period.
Carels responded with a short-handed goal a few minutes later. Heffernan and Murray added insurance goals early in the final period.
Canada outshot Hungary 35-11.
In other preliminary round games, Finland edged Germany 3-2, the United States dumped Russia 7-0 and Sweden defeated the Czech Republic 3-2.
Canada will play host Finland on Sunday.
"We're expecting the same type of challenge that we got from Hungary tonight," Fetter said. "They're at home, they're going to want to impress."
The playoff round begins Wednesday and the medal games are set for next Saturday. Canada won last year's tournament in the Czech Republic.Suggest a correction