# SecureVision: An Open-Source User-Customizable Image Encryption Program
## Materials and Methods  
### Random Number Generator  
A custom-made random number generator based on the equation of ellipse was developed. This was needed because the random sequences needed to be reproducible upon image decryption, when the user input the correct keys used for image encryption. In this method, the keys were actually the \(x\)-coordinate, and major and minor axes of an ellipse, where the decimal part of the \(y\)-coordinate would be used (see Figure 1). As shown in Figure 1, for a specific major axis \(a\), minor axis \(b\) and \(x\)-coordinate, there would be a specific \(y\)-coordinate value. The equation to determine the \(y\)-coordinate value is:  
\[y=\sqrt{b^{2}-\frac{b^{2}}{a^{2}}x^{2}}. \tag{1}\]  
The obtained \(y\)-coordinate was then multiplied with the remainder of \(y\) and _deno_, which could be represented as mod(\(y\),_deno_). The value of _deno_ itself is another user-defined key that requires the user to input. The program changed the minor axis \(b\) of the ellipse according to the width and height of the image loaded into the program for encryption. The decimal part of the \(y\)-coordinate value multiplied by the modulo operation as discussed above was used as a random number between 0 and 1. It is remarked that the absolute value was taken. To assess the randomness of our generated results, we compared these with the built-in uniform random number generator in FORTRAN90 programming language (see Figure 2). The results shown in Figure 2 were for 1000 iterations. The random numbers generated from our model were compared against those generated by FORTRAN90, and the randomness of both sets of random numbers were similar. Moreover, we evaluated the distribution of differences between the random numbers generated by our model and those from the standard FORTRAN90 routine, which is shown in Figure 3.  
Figure 1: Schematic diagram showing an ellipse with major and minor axes, centered at the origin of the Cartesian coordinate system. Figure 2: Graphical comparison between random numbers generated using our model (black squares) and the FORTRAN90 compiler (blue circles) for 1000 iterations. Figures 2 and 3 show that the pseudo-random numbers generated from our model and the standard FORTRAN90 routine were similar. The peak of the distribution of differences lay in the bin with a range from 0 to 0.1. The mean of the differences was found to be \(-7.55\times 10^{-3}\), which was very close to zero. In addition to the comparison shown in Figures 2 and 3, a more extensive benchmarking using a numerical example was performed. Here, we computed the value of \(\pi\) by way of Monte Carlo simulations using the two random number generators. The source code for these Monte Carlo simulations can be found at: [[https://figshare.com/articles/software/SecureVision_A_versatile_open-source_image_encryption_program_for_students/14946054](https://figshare.com/articles/software/SecureVision_A_versatile_open-source_image_encryption_program_for_students/14946054)]([https://figshare.com/articles/software/SecureVision_A_versatile_open-source_image_encryption_program_for_students/14946054](https://figshare.com/articles/software/SecureVision_A_versatile_open-source_image_encryption_program_for_students/14946054)) (accessed on 21 August 2021). The variables were double-precision 8-byte real numbers (i.e., real*8 type), and the code was written in standard FORTRAN90 and compiled using Gfortran (GNU Fortran). From \(10^{6}\) iterations, the values of \(\pi\) were determined to be 3.1411 and 3.1416 respectively, using random number generators from our model and the standard FORTRAN90 routine, which could be considered close. A computer routine in the C++ language, which is one of the commonly used programming languages, has been used to provide data for comparing the randomness. From 106 iterations, the values of \(\pi\) were determined to be 3.1424 and 3.1414 respectively, using random number generators from our model and the standard C++ routine.