Need to generate same ciphertext everytime I am developing in android and working with numeric ids. Say for e.g., 5001.

I upload videos with this id prefixed in in the uploaded video's name.

For e.g. 5001_profile_video.mp4 is a filename. Then if 5001 gets encrypted to xx841jf==, the file name would be xx841jf==_profile_video.mp4.

I need this to be same every time. Say I uploaded video for profile id 5001, the and the file name was xx841jf==_profile_video.mp4. Then, next time I retrieve video for id 5001 I should be able to form part of  the file name as xx841jf== for retrieving video from server.

I need to encrypt 5001 but I need it to be same every time I call the encrypt method. I am currently using Cipher class in java but the results are different every time. 

What should I do? Is encryption what I should be looking for OR should I look for something else?
If you use a small value such as xx841jf== to retrieve a video then a hacker can simply brute force the URL by iterating over all the values. Similarly, if you use a hash over the number (5001) then the attacker can simply go over all numbers, perform the hash and perform the same attack.

There are a few good options for doing this:


Use a block cipher to encrypt the number value. In that case you need to pad the encoded number to a full block (using bit padding or PKCS#7 padding, for instance) and then the full result. This can be reversed to the number by the server.
Similarly you can use a hash over the number and a secret value (a pepper) to calculate a unique number, and then take the leftmost bits in case you want to shorten the URL (you'd still want at least 64 bits otherwise you may mistakenly reuse hash output values).
Often unique, large, random ID (a UID) is used to link to the number.




Notes:


For the first option you could use a 64 bit block cipher (e.g. Blowfish) or a 128 bit cipher such as AES. AES is more secure, but the URL will be much larger.
If direct encryption with the block cipher is not available then you could choose AES in ECB mode using PKCS#7 padding which is commonly available.
Of course you'd need to keep a table for the last two options, otherwise you cannot reverse the URL to the number and thus filename.
Instead of using standard base 64 encoding you could have a look at base-64-url encoding, which is URL-safe and thus doesn't require URL escaping.