Being the only nonlinear component in many cryptosystems, an S-box is an integral part of modern symmetric ciphering techniques that creates randomness and increases confidentiality at the substitution stage of the encryption. The ability to construct a cryptographically strong S-box solely depends on its construction scheme. The primary purpose of an S-box in encryption standards is to establish confusion between the m-bit input into the n-bit output (both m, n >= 2). This article proposed a robust way to construct S-boxes based on the Gravesian octonion integers. We chunk the paper into threefold: firstly, a comprehensive technique for constructing S-box using affine mapping is described. The presented work is developed in such a way that for every valid input, it generates two S-boxes. Secondly, the strength of the newly generated S-box is evaluated by passing through a rigorous security analysis. Finally, a thorough comparison of the newly developed method with some well-known existing schemes is conducted. We mainly targeted some elliptic curve-based S-boxes in comparison by taking the same parameters in our scheme. The computational results and performance analysis reveal that the propose algorithm can construct a large number of distinct S-boxes that are cryptographically secured and create high resistance against various cryptanalysis attacks.