mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-26 16:35:39 +00:00
Rename files part 2
This commit is contained in:
12
src/app/Utils.ts
Normal file
12
src/app/Utils.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
const dec2hex = (dec: number) => ('0' + dec.toString(16)).substr(-2)
|
||||
|
||||
export function hexId(length = 12) {
|
||||
var arr = new Uint8Array(length / 2)
|
||||
window.crypto.getRandomValues(arr)
|
||||
return Array.from(arr, dec2hex).join('')
|
||||
}
|
||||
|
||||
export function htmlEncode(str: string) {
|
||||
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
||||
.replace(/"/g, '"').replace(/'/g, ''').replace(/\//g, '/')
|
||||
}
|
||||
Reference in New Issue
Block a user