Vietnam¡¯s new cybersecurity law could force Alphabet Inc.¡¯s Google and Facebook Inc. to choose between access to one of Asia¡¯s fastest-growing digital economies and protecting their users¡¯ privacy.

The law, which goes into effect Jan. 1 after the National Assembly passed it this month, requires foreign internet companies to store data within the country and open local offices. If requested, they¡¯ll also be required to hand over to the government the data of users suspected of anti-state activity ¡ª including spreading news that may impede Hanoi or hurt the economy.

The law mirrors efforts globally to safeguard domestic users¡¯ information and open up access to data that governments say they need to combat threats ¡ª what China refers to as its cybersovereignty. It also reflects a growing wariness about the influence of internet and social media giants that handle and parse information on and for billions around the world.