Abstract The XOR Lemma states that a mapping is regular or balanced if and only if all the linear combinations of the component functions of the mapping are balanced Boolean functions. The main contribution of this paper is to extend the XOR Lemma to more general cases where a mapping may not be necessarily regular. The extended XOR Lemma has applications in the design of substitution boxes or S-boxes used in secret key ciphers. It also has applications in the design of stream ciphers as well as one-way hash functions. Of independent interest is a new concept introduced in this paper that relates the regularity of a mapping to subspaces