Photodetectors (PDs) with broadband photoresponse can meet the demand for multiband detection in complex environments, overcoming the technological complexity issue of integrated narrow-band PDs. Self-powered heterojunction PDs having ultraviolet–visible–near-infrared broadband photoresponse were constructed by using SnO2 nanopillars and CuInS2 nanoflakes. The dimension, crystalline quality, and energy level structure of the SnO2 nanopillars were regulated by changing the concentration of Sn ions in the precursor solution. The optimized interfacial energy band structure of the heterojunction can increase the transfer ability of the photogenerated carrier. The optimum performance is achieved for the CuInS2/SnO2(0.025M) PD prepared at 0.025 M Sn ion concentration in the precursor solution with the responsivities of 1.15, 6.13, and 1.02 mA/W, and detectivities of 1.19 × 1010, 6.35 × 1010, and 1.02 × 1010 Jones under 254 nm solar-blind ultraviolet light, 475 nm visible light, and 940 nm near-infrared light. Furthermore, a proof-of-concept solar-blind ultraviolet–visible–near-infrared encrypted communication system utilizing a broadband self-powered CuInS2/SnO2 PD as the receiving terminal and solar-blind ultraviolet light, ultraviolet light, visible light, and near-infrared light as the carrier and encryption protocol is proposed. The PD has great potential for applications in the field of encrypted optical communication.