nblackburn
9/16/2017 - 12:48 PM

String Checksum

Calculate the checksum of a string.

module.exports = (string) => {

    let index;
    let checksum = 0x12345678;

    for (index = 0; index < string.length; index++) {
        checksum += (string.charCodeAt(index) * (index + 1));
    }

    return checksum;
}