For AB testing purposes we generate a unqiue hash of a user Id into a bucket value in VCL (by Fastly CDN).
set var.backResult =
randomint_seeded(1, 4,
std.strtol(
substr(
digest.hash_md5(req.http.X-Development-UserId)
, 0, 8),
16)
);
This start by hashing the user id to a MD5 string. Then the first 8 chars. are used in the std.strtol
function what converts it to a integer value. That value is then used as a seed to the randomint_seeded
function.
We're struggling doing the same functions as std.strtol
and randomint_seeded
in any other language (looking for PHP or javascript). We need to have the same result in different languages.
Any suggestions on this?