I ran into an issue with my server that made me ask a question - is AES-256 encryption reliably consistent?

So my node server, to avoid DDOS vulnerabilities while keeping user data anonymous, takes an IP from the request, encrypts it, and stores the number of times it has made a request in the last 24 hours.

It checks if the user had made a request in the last 24 hours by re-encrypting the IP using the exact same password. It then, takes that and matches it with the first stored IP.

But then:

Error: Can't find data: /ipcount/d00c526612cec9e5d3e201af35993c75. Stopped at ipcount

d00c526612cec9e5d3e201af35993c75 should be the encrypted string, but the database is acting like it's never seen it before. So can I have it encrypt consistently with the same password?

Thanks in advance.

closed as off-topic by Maarten Bodewes, e-sushi Dec 4 '17 at 3:38

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions are off-topic even if you are writing or debugging cryptographic code. Unless your question is specifically about how the cryptographic algorithm, protocol or side-channel (mitigation) works, you should look into asking on Stack Overflow instead." – Maarten Bodewes, e-sushi
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Please post this including the source code at stackoverflow. This is an implementation issue which is off topic here. Without the code we can only guess anyway. – Maarten Bodewes Dec 4 '17 at 2:12

AES-256 is a function from a 256-bit key and a 128-bit plaintext block to a 128-bit ciphertext block. Same key and plaintext, same ciphertext.

But it is unlikely that your application uses AES-256 directly—most applications don't, because most applications are concerned with encrypting messages, not with permuting the set of strings of 128 bits. From the information you've given, there's no way for us to know how you use AES-256, or even if you do use it directly, whether there's an application bug that just causes some wrong IP address to be stored or retrieved or causes some IP addresses to be dropped on the floor.

Not the answer you're looking for? Browse other questions tagged or ask your own question.