2020-07-27 15:06:12 +00:00
|
|
|
import { createHash } from "rusha";
|
2020-08-10 21:34:30 +00:00
|
|
|
import crc32 from "crc/crc32";
|
2020-07-27 15:06:12 +00:00
|
|
|
import { decompressX64 } from "./lzstring";
|
2020-05-09 14:45:23 +00:00
|
|
|
|
|
|
|
export function sha1(str) {
|
2020-07-27 15:06:12 +00:00
|
|
|
return createHash().update(str).digest("hex");
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Window.location.host
|
|
|
|
export function getNameOfProvider() {
|
2020-07-27 15:06:12 +00:00
|
|
|
return window[decompressX64("DYewxghgLgliB2Q")][decompressX64("BYewzgLgdghgtgUyA")];
|
2020-05-09 14:45:23 +00:00
|
|
|
}
|
2020-08-10 21:31:02 +00:00
|
|
|
|
|
|
|
// Distinguish legacy crc prefixes
|
|
|
|
export const CRC_PREFIX = "crc32".padEnd(32, "-");
|
2020-08-10 21:34:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Computes the crc for a given string
|
|
|
|
* @param {string} str
|
|
|
|
*/
|
|
|
|
export function computeCrc(str) {
|
|
|
|
return CRC_PREFIX + crc32(str).toString(16).padStart(8, "0");
|
|
|
|
}
|