Both the act of keeping information secret and the research on how to achieve it are included in the broad category of cryptography. When people refer to “information security,” they are referring to the study and use of methods that make data transfers harder to intercept. When we talk about “information security,” this is what we have in mind. Using private keys to encrypt and decode messages is a part of this procedure. Because of its vital role in modern information theory, computer security, and engineering, cryptography is now considered to be a branch of both mathematics and computer science. Because of its mathematical properties, the Galois field may be used to encrypt and decode information, making it relevant to the subject of cryptography. The ability to encrypt and decode information is one such use. In this case, the data may be encoded as a Galois vector, and the scrambling process could include the application of mathematical operations that involve an inverse. While this method is unsafe when used on its own, it forms the foundation for secure symmetric algorithms like AES and DES when combined with other bit shuffling methods. A two-by-two encryption matrix is used to protect the two data streams, each of which contains 25 bits of binary information which is included in the proposed work. Each cell in the matrix represents an irreducible polynomial of degree 6. Fine-tuning the values of the bits that make up each of the two 25-bit binary data streams using the Discrete Cosine Transform (DCT) with the Advanced Encryption Standard (AES) Method yields two polynomials of degree 6. Optimization is carried out using the Black Widow Optimization technique is used to tune the key generation in the cryptographic processing. By doing so, we can produce two polynomials of the same degree, which was our original aim. Users may also use cryptography to look for signs of tampering, such as whether a hacker obtained unauthorized access to a patient’s medical records and made any changes to them. Cryptography also allows people to look for signs of tampering with data. Indeed, this is another use of cryptography. It also has the added value of allowing users to check for indications of data manipulation. Users may also positively identify faraway people and objects, which is especially useful for verifying a document’s authenticity since it lessens the possibility that it was fabricated. The proposed work achieves higher accuracy of 97.24%, higher throughput of 93.47%, and a minimum decryption time of 0.0047 s.