Files
mattermost-mobile/app/utils/security.ts
Elias Nahum 17e832e689 [Gekidou] Refactor storage layer (#5471)
* Refactored storage layer - in progress

* Refactored DatabaseManager & Operators

* Renamed isRecordAppEqualToRaw to isRecordInfoEqualToRaw

* Review feedback

* Update app/database/models/app/info.ts

Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>

* Update app/database/models/server/my_team.ts

Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>

Co-authored-by: Avinash Lingaloo <>
Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>
2021-06-21 17:06:18 -04:00

26 lines
691 B
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import CookieManager from '@react-native-community/cookies';
export async function getCSRFFromCookie(url: string) {
const cookies = await CookieManager.get(url, false);
return cookies.MMCSRF?.value;
}
export const hashCode = (str: string): string => {
let hash = 0;
let i;
let chr;
if (!str || str.length === 0) {
return hash.toString();
}
for (i = 0; i < str.length; i++) {
chr = str.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
return hash.toString();
};