Maybe in a very weird way we could find a utility for something like this. For example having an indicator of what the private key was used for (eg. MyHotWallet). But as others mentioned you are reducing the security of the private key so here is a better idea: why don't you use a different encoding and change the algorithm itself?
that means instead of modifying the key itself, you could just add extra bits on top of the untouched random 256-bit key to indicate the utility.
You don't even have to reinvent the wheel, there is Bech32[1] encoding that is very suitable for this purpose. You just replace the HRP part with the string you want. It can contain between 1 to 83 US-ASCII characters then use the key bytes as the data part without modifying it at all. So your final key string would become something like this: MyFirstBitcoinAddress
1{unchanged 256-bit encoded key} where 1 is the default separator.
I used a version byte (=0) and the BIP350 (Bech32m)[2] in the following:
5JYkir7TsJ4L8bJroCuLgjxxNdbEUgvjVKdUgnwhDMFF5yM2dYu
MyFirstBitcoinAddress1qvpkmem0ne8c5mc2mx69733mxcq206rfhwnln8g5p7javkv26f6dsqdk50w
5JYkir7... is a randomly generated key without modification and second line MyFirs.... is the different encoding of the same exact key without any difference between the key bytes whatsoever.
This has so many benefits:
- It doesn't reduce key security
- The restriction on the size of the "string" you use at the beginning is big enough (83 chars) to contain any note
- You don't have to write that much code to guess the range like you did here, everything is pretty straight forward and you can use already existing Bech32 encoding libraries
- The code and the result is neat and is easy to verify so the chance of bugs is minimal
- The encoding is fast and has a checksum and error detection built in.
- It can contain a version for future expansion of the algorithm
[1]
https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki[2]
https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki