Whenever you have two functions such that, for any X and any Y,
X == S(P(X))
and also
Y == P(S(Y)),
then
X and Y are bijective functions.
With modern secure communication systems, exactly the same plaintext message can be encrypted to many different ciphertext messages -- in particular, they are designed such that the message "attack" is unlikely to encrypt to the same ciphertext twice -- so therefore their "encryption" and "decryption" functions are not bijective.
Nevertheless, many classic ciphers are bijective, and often several of the parts inside a modern secure communication system are also bijective.
(The complete ciphertext message for a modern secure communication system typically begins with a random initialization vector or other nonce, has a "body" generated by some bijective function applied to the plaintext -- the particular bijective function is selected by a combination of the initialization vector and the encryption key -- and ends with a message authentication code.).
reciprocal ciphers
A cipher where P() and S() are not only bijective, but are the same function -- i.e., for any X, P(X) == S(X), and X == P(P(X)) -- is common, and known as a reciprocal cipher.
Some of the more famous reciprocal ciphers are:
- The Enigma machine was a reciprocal cipher machine
- ROT13
- Beaufort cipher
- Kama-sutra ciphers
- XOR-based stream ciphers
- One Time Pads (both XOR and Beaufort cipher versions)
Most mechanical cipher machines use a reciprocal cipher, so it wouldn't need a separate "encode mode" and "decode mode".
non-reciprocal bijective ciphers
Many classic ciphers are bijective, but not reciprocal: S(X) != P(X).
For example, the following ciphers are bijective but (usually) not reciprocal:
- monoalphabetic substitution ciphers (except for Kama-sutra ciphers), and in particular the Caesar cipher (except for ROT13).
- The standard Vigenère cipher, and the "variant Beaufort" cipher.
- One Time Pads (the Vigenère cipher version)
- transposition cipher (except for a few "paired-up" reciprocal transpositions)
- permutation cipher
Practically all modern ciphers are based on either stream ciphers (RC4, A5/2, Solitaire cipher, etc.) or single-block ciphers (AES, DES, etc.), which are bijective but (almost always) not reciprocal.
Many modern single-block ciphers are built with a Feistel network structure that, in each round, cascades a reciprocal permutation E ("swap the left and right half of the block") and a keyed reciprocal substitution cipher U, to build a non-reciprocal bijective encryption function S(x) == E(U(X)) != P(X) = U(E(X).
It is widely believed that practically any non-linear function can give adequate security if it is iterated over enough rounds.
(Is it a coincidence that you used the names S() and P() that have the first letter of two common operations in cryptography, substitution and permutation, aka confusion and diffusion ?)
security
These bijective ciphers (both reciprocal and non-reciprocal) have a wide range of security, covering both ends of the spectrum:
- Monoalphabetic substitution ciphers (aka cryptograms) published in newspapers as puzzles that are daily cracked by amateurs.
- One-time pads which (in both reciprocal versions, and also the non-reciprocal version) are uncrackable.