Skip to content

Instantly share code, notes, and snippets.

@xjoker
Created December 23, 2021 10:09
Show Gist options
  • Save xjoker/0fed1c28125fd9a9993bcde1c65084d5 to your computer and use it in GitHub Desktop.
Save xjoker/0fed1c28125fd9a9993bcde1c65084d5 to your computer and use it in GitHub Desktop.
小红书x-s算法
var encFunc = function (inValue) {
var result = "";
var v1, v2, v3, v4, v5, v6, v7;
var index = 0x0;
var secDict =
"A4NjFqYu5wPHsO0XTdDgMa2r1ZQocVte9UJBvk6/7=yRnhISGKblCWi+LpfE8xzm3";
while (index < inValue.length) {
v1 = inValue.charCodeAt(index++);
v2 = inValue.charCodeAt(index++);
v3 = inValue.charCodeAt(index++);
v4 = v1 >> 0x2;
v5 = ((v1 & 0x3) << 0x4) | (v2 >> 0x4);
v6 = ((v2 & 0xf) << 0x2) | (v3 >> 0x6);
v7 = v3 & 0x3f;
if (isNaN(v2)) {
v6 = v7 = 0x40;
} else if (isNaN(v3)) {
v7 = 0x40;
}
result =
result +
secDict.charAt(v4) +
secDict.charAt(v5) +
secDict.charAt(v6) +
secDict.charAt(v7);
}
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment