aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src/utils/hashUtils.ts
blob: 607064947a8bee132f6327c567c2a4d9c2622daf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
/**
 * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

export const hashCode = function(str: string): number {
	let hash = 0
	for (let i = 0; i < str.length; i++) {
		hash = ((hash << 5) - hash + str.charCodeAt(i)) | 0
	}
	return (hash >>> 0)
}