angular-md5
angular-md5 copied to clipboard
Crash when generating hashes for single-digit numbers
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);
If you cast your int to String via currentId.toString(), the error won't be thrown.