In wireless sensor networks (WSNs), security, efficiency, and energy consumption are still major challenges due to its open, large-scale, and resource-constrained nature. The 6LoWPAN protocol and many other lightweight cryptographic methods have been developed to improve the security and efficiency of WSNs with a reasonable amount of energy and resource utilization. However, they still suffer from limitations in terms of flexibility, key management, authentication, and the power resource management processes. This paper addresses these issues by designing FlexCrypt, an automated lightweight cryptographic scheme for WSNs. In the FlexCrypt scheme, a new dynamic clustering technique that supports mobility among the sensor nodes is developed. Moreover, the proposed scheme introduces a flexible lightweight cryptographic method to control the complexity of the encryption by automating the selection of encryption parameters based on the presently available resources of each sensor node to encrypt the data. In addition, a new lightweight key management and authentication method is designed to establish secure communication and the exchange of data and keys among the various WSN nodes. The proposed FlexCrypt scheme was evaluated using the Cooja simulator with Contiki OS. The results prove that the proposed scheme provides a significant improvement in terms of delay and encryption time in addition to power consumption and network lifetime compared to other ciphers that use fixed encryption parameters. It can effectively extend the network lifetime by 86 percent, 94 percent and 90 percent compared to the FlexenTech, AES and TEA ciphers, respectively. The security analysis demonstrates that the FlexCrypt scheme can resist various attacks such as brute-force, eavesdropping, man-in-the-middle and replay attacks.