mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 12:07:11 +03:00
Get username for warning chat
This commit is contained in:
11
src/utils.ts
11
src/utils.ts
@@ -492,14 +492,13 @@ export default class Utils {
|
||||
async getHash(value: string, times = 5000): Promise<string> {
|
||||
if (times <= 0) return "";
|
||||
|
||||
let hashBuffer = new TextEncoder().encode(value).buffer;
|
||||
|
||||
let hashHex = value;
|
||||
for (let i = 0; i < times; i++) {
|
||||
hashBuffer = await crypto.subtle.digest('SHA-256', hashBuffer);
|
||||
}
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(hashHex).buffer);
|
||||
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||
hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
}
|
||||
|
||||
return hashHex;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user