I have an application that involves processing packets of IDs from a variety of sources. Some of these sources contain the information I want, some of them constitute, effectively, noise. Currently, whenever my application receives a data packet, it checks the database to verify that the received IDs match internal data before doing more work. I would like to eliminate this step and/or minimize the processing due to noise.
One idea I had was to make some portion of my IDs non random. E.g. instead of using a completely random UUID, I might replace the last four characters with a fixed string - thus my application can perform a simple check that will be able to easily filter out the noise 99.9% of the time.
However, this seems... dirty...
Another idea would be to create hashes from some bit of random string and some other constant. Hence when un-hashed, I could locally detect if the constant matched. However, this just seems like adding a layer of complexity on top of the dirty solution.
How should I best deal with this situation? Am I right in my instinct that my proposed solution is a potentially bad idea?
Each time my application (a mobile app) receives a packet (bluetooth low energy beacon data), it sends a request to a server (AWS lambda function), which then queries the database (DynamoDB) to find the ID and responds with the result of the query. Servers, database throughput, and API calls cost money. Hence, reducing the number of times I have to perform this operation reduces my costs. Furthermore, I feel that minimizing the total amount of bandwidth I'm requiring from my users mobile phones is just a nice thing to do.