I am doing some research on cryptography, so I generated a random string of numbers resembling a creditcard number(according to MOD10 validation) and encrypted it with SHA1 algorithm for encryption. But to make this interesting, I decided to make my database column size exactly 2/3 smaller than the encrypted text so that it is truncated on save. So now I have in my database 2/3 of a SHA1 hash, and I want to reverse engineer it so I can recover my original full hash.
Things to consider:
- I also saved the original hash just for final comparison purposes
- To make things easier on me and give more possibilities, I saved the creditcard generated as a masked number in the format 000000****0000(for whatever use you can think of that will help)
- I didn't post any code since it is irrelevant and unnecessary to this question.
- This is not just a regular SHA1 algorithm. I tweaked it the procedure before to add some variables like current time and other variables to original encrypted number, in order to make that if you encrypt the same word twice in a row, both results won't be equal(as a matter of fact, I tested it with over 100k encryptions in a row and not a single hash was equal to the first one generated, even though the words encrypted were the same), but you can get the original value out of both of them nonetheless.
- I have access to the certificate that controls the encryption, so the hardest part is theoretically past behind, right?
Anyways... my question is how to recover the hash for the creditcard number generated before, knowing that I got the first 2/3 of the hash and the certificate used to create it? Is brute force the only available or possible solution?