In collaborative networked microgrids (NMs), distributed energy resources (DERs) utilize intelligent IoT based controllers to coordinately support various smart community functions. Meanwhile, privacy and security issues occur when IoT-based controllers interact with each other. This paper presents a cryptography-based, programmable control (crypto-control) scheme to provably preserve the privacy of DERs while ensuring fast, flexible distributed control in NMs. Specifically, it makes the following contributions: 1) a programmable crypto-control-based NMs (PCNMs) architecture, where crypto-controllers are fully virtualized, is devised; 2) a novel dynamic encrypted weight addition (DEWA) approach, which integrates an enhanced partial homomorphic encryption and a secret sharing scheme, is devised to ensure privacy preserving of distributed controls; 3) the DEWA privacy-preserving property is mathematically analyzed; and 4) a real-time DEWA-based PCNMs testbed is deployed by incorporating DEWA, real software defined networking switches, and IoT devices. The deployable crypto-control scheme is interfaced with and thoroughly verified in a Real-Time Digital Simulator environment, and the experimental results validate the effectiveness, benefits, and superiority of DEWA-based PCNMs. The inherent resilience of the DEWA-based PCNMs is validated by small signal stability analyses.