Security of password hash with known prefix and appendix Assume I have a password that is exactly 32 characters long. I hash it the following way:


Prepend 1524 bytes (known to an attacker)
Append 3356 bytes (known to an attacker)
Do the checksum


It is clearly visible that only a tiny part of the plaintext is variable.

Assume the attacker stole the checksum from a DB. How difficult would it be for them to recover the password or create a collision? What checksum algorithms are more resistant against that?

Yes, I know that one cannot recover a password from a 16-bit CRC-16. Let's assume that the checksum is at least 128 bits long.

What would change if one of pads would disappear?
Except against rainbow tables, it makes no difference whether you've prepended or appended any bytes if they're known and static. Both may as well not exist.

So the scenario is reduced to "doing a checksum of" (presumably trying to hash) a 32-byte password. 

There isn't a CRC-128 in common use, but if you extended the CRC algorithm to 128 bits, you'd get a completely insecure transformation. CRC was designed for simplicity and low collision probability, making it reversible. There's a paper specifically on reversing CRC - https://sar.informatik.hu-berlin.de/research/publications/SAR-PR-2006-05/SAR-PR-2006-05_.pdf - and the process can be implemented by a decent high school student.

Algorithms resistant to that - producing a true one-way transformation - are called hashing algorithms, not checksums. Popular examples of hashing algorithms include SHA-3 and SHA-2.

For passwords specifically, an even higher level of security is often called for, such as using key derivation functions (PBKDF) - bcrypt, scrypt, argon2. In addition to the quasi-randomness property that hashes have and CRC don't, PBKDF deliberately tie up additional computer resources to somewhat improve their brute-force resistance.