US prosecutors charged two Chinese nationals with computer hacking attacks on American government agencies and corporations, including the Navy and Nasa.