Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when generating hashes for single-digit numbers #7

Open
blaues0cke opened this issue Jun 19, 2015 · 1 comment
Open

Crash when generating hashes for single-digit numbers #7

blaues0cke opened this issue Jun 19, 2015 · 1 comment

Comments

@blaues0cke
Copy link

This code will throw some js errors:

var currentId = 1;

FormIDProvider.getCurrentId = function (raw)
{
    if (raw)
    {
        return currentId;
    }

    return 'form-field-' + md5.createHash(currentId);
};

The console says:

RangeError: Invalid array length
   at convertToWordArray (/assets/js/angular/angular-md5.js:88:28)
    at Object.md5.createHash (/assets/js/angular/angular-md5.js:114:13)

As a workaround, this will help:

return 'form-field-' + md5.createHash('seed' + currentId);
@karsasmus
Copy link

If you cast your int to String via currentId.toString(), the error won't be thrown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants