I'm working with firebase firestore and for some reason I need to hash every new user document ID to integer specifically a 16Bit UTF integer. Mostly it's an attempt at duplicating the .hashcode method in Dart.
what I have found and tried is this
// Convert to 32bit integer
const hashFunction = (string) => {
var hash = 0;
if (string.length == 0) return hash;
for (i = 0; i < string.length; i++) {
char = string.charCodeAt(i);
hash = (hash << 5) - hash + char;
hash = hash & hash;
}
return hash >>> 0; // returns hash as positive integer
};
but this only converts to 32bit int. Any and all help is appreciated.
EDIT1: Using @selbie's changes i made some progress but the hash i'm getting is quite different from the .hashCode method in Dart
and 
is there anyway i can get thesame result
hashsupposed to be? int16? int32? uint32? uint16? something else?2328644ain't a 16 bit value. That are at least 22 bits. Where did you get the source code for yourhashFunctionfrom? I wasn't able to locate that function in the dart repo.