0

I have HTTP_USER_AGENT, list of system fonts and other characteristics. Have rather long text.

Is it possible to convert the text to unique string?

Idea is following:

No login in website.

1) Visitor clicks to send message from website.

2) I try to identify visitor. Get browser fingerprints (rather long text). Convert the text to unique string.

3) Then check if the same string already exists in mysql. If exists, then i have some information (recorded in mysql) if the visitor before did good things or bad things.

4) If in mysql no the unique string (created from fingerprints), then record in mysql and deem visitor as "bad visitor". Do full checking of message.

String must be unique, fixed length. And from the same fingerprints always must get the same string (no random).

I tried to create something based on https://stackoverflow.com/a/6382880/2118559

$value_ = unpack('H*', "Some long text as example...");
echo $value_[1]. ' $value_[1] __ <br/>';

First problem, the longer text, the longer is $value_ Is it possible to make it fixed length.

echo base_convert($value_[1], 16, 2). ' base_convert _ <br/>';
echo pack('H*', base_convert(base_convert($value_[1], 16, 2), 2, 16)). ' -- pack base_convert1 <br/>';

Got unexpected results.

May be need to do in other way? Some function that creates unique, not random string from text?

What if http://us3.php.net/manual/en/function.crc32.php ?

Tried

$checksum = crc32("The quick brown fox jumped over the lazy dog. Some long string. ");
echo printf("%u", $checksum). ' checksum -- <br/>';

Reloaded browser, see the same number. Tried from different browsers, see the same number. Tried 3 different lengths of text, see the same length number (12 characters/digits).

Does crc32 create unique number based on text (unique text means that i get unique number)?

Seems it is unique enough What is the maximum value for an int32? (more than two billion variations)... However https://stackoverflow.com/a/5099354/2118559

CRC was designed to prevent transmission errors, not malicious action.

Therefore, it isn't collision resistant.

Community
  • 1
  • 1
Andris
  • 1,434
  • 1
  • 19
  • 34
  • not only user agent. https://panopticlick.eff.org/index.php?action=log&js=yes https://www.browserleaks.com/ https://wiki.mozilla.org/Fingerprinting – Andris Feb 26 '15 at 07:08
  • 1
    I'm not quite sure what you are asking for. You might be looking for a hash algorithm like [sha1](http://php.net/manual/en/function.sha1.php). – martin Feb 26 '15 at 07:35
  • From text need to create fixed length, unique and not random string or better integer. – Andris Feb 26 '15 at 07:37
  • Yes, seems `sha1` also ok. – Andris Feb 26 '15 at 07:40

0 Answers0