Basic hashing function in AngularJS