I would like to write a bash script to rename all the files in this folder, by using some standard hashing algorithm, so that the directory now looks something like this -

Lets assume that the hashing key is common_key = "mykey123"

Directory images -
U2FsdGVk.jpg
X1O9Z6e.jpg
ECdjybF.jpg
U2FsdGVajpg

How can I achieve this ?

Furthur, I am writing some code in Nodejs (basically javascript), where I wish to pick a random image out of these four and display it, so I am using-

var random_image_number = Math.floor((Math.random()*4)+1); // Picking a random number out of 4

Suppose random_image comes out to be 3. Now I need to display image number 3. If I had not hashed the image names, I would normally do this -

<img src="/images/" + random_image_number + ".jpg" />

But now I need to use the standard encryption algorithm again on the random number that I have generated, before I can display the image. (I keep stressing on "standard" since the same hashing algorithm has to work on JS side as well as in the bash script and generate the same result)