It is an important challenge to find out suitable cryptography for wireless sensor networks (WSN) because of the limitations of power, computation capability, and storage resources. Many schemes based on public or symmetric key cryptography are investigated. Recently, a practical identity-based encryption technique is proposed. In this article, we present an identity-based key agreement and encryption scheme for WSNs. This scheme is an elliptic curve cryptography type algorithm. First, we briefly review regarding identity-based encryption and decryption, particularly, the Boneh-Franklin algorithms. Then we describe a key agreement and encryption scheme on the basis of the Boneh-Franklin algorithms for WSNs. We discuss the efficiency and security of our scheme by comparing it with traditional public key technique and symmetric key technique.