java - IP compression for database storage -


I have a database that stores the IP number of all users who have used a feature (i.e.: anyone Voted on polling), and I want to avoid voting twice from the same user or IP.

As a result, I am collecting all the IPs of anonymous users who have voted in my elections. My database is full of IPs like 123.456.789 ...

However, it is disabled, does one function reduce the function and IP in low string?

Like 123.456 = 798 = & gt; For IPv4, you can insert an IP address from int such as int it:

  scanner scanner = new scanner (IP) .Usedelimeter ("\\."); Int value = (scanner.nextInt () <24  (Scanner.nextInt () << 16) | (Scanner.nextInt ()   

It can also be reversed:

  string ip = ((value> 24) & amp; 0xFF) + " . " + ((Value> gt; & gt; 16) & amp; 0xFF) + "." + ((Value> 8> & amp; 0xFF) + "." + (Value & amp; 0xFF);    

Comments