Code Monkey home page Code Monkey logo

cyrb53-hasher's Introduction

Cyrb53 Hasher (ssGTM)

Custom Variable Template for Server-Side Google Tag Manager

Hash any string using cyrb53. This variable needs a string as input and calculates a hash based on the function on Stack Overflow described at https://stackoverflow.com/a/52171480.

Template Status Repo Size License


Note: As the GTM JS Sandbox does not support all methods that are uses in the orignal function, the template uses some polyfills and has to make compromises regarding the supported set of characters. That means, that all parts consisting of unknown characters besides the standard ASCII set will lead to the same result. If a string can not avoid including characters that are not part of the following string, the distribution will suffer - and lead to a result that does not match the outcome of the original function. If you need to compare hashes on the receiving side, an adjusted cyrb53 version similar to this variable implementation must be used.

Supported Characters

const asciiString = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~';

Parameters

Parameter Description
Data String the string to be hashed. If a salt is used, it has to be already added to the value
Seed alters the hash similar to the original function
64-bit Output Changes the hash format. Uncheck to get the result of the initial example function. With the option checked, the function uses a alternative hash format from the comments

Tests

The tests included in the template check the sample results from the answer on Stack Overflow. Quote:

"501c2ba782c97901" = cyrb53("a")
"459eda5bc254d2bf" = cyrb53("b")
"fbce64cc3b748385" = cyrb53("revenge")
"fb1d85148d13f93a" = cyrb53("revenue")

You can optionally supply a seed (unsigned integer, 32-bit max) for alternate streams of the same input:

"76fee5e6598ccd5c" = cyrb53("revenue", 1)
"1f672e2831253862" = cyrb53("revenue", 2)
"2b10de31708e6ab7" = cyrb53("revenue", 3)

cyrb53-hasher's People

Contributors

mbaersch avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.