(str: string)
| 177 | * Deterministically hashes a string and turns the hash into a uuid. |
| 178 | */ |
| 179 | export function stringToUUID(str: string): string { |
| 180 | const sha256Hash = crypto.createHash('sha256').update(str).digest('hex'); |
| 181 | |
| 182 | // Position 16 is fixed to either 8, 9, a, or b in the uuid v4 spec (10xx in binary) |
| 183 | // RFC 4122 section 4.4 |
| 184 | const v4variant = ['8', '9', 'a', 'b'][sha256Hash.substring(16, 17).charCodeAt(0) % 4] as string; |
| 185 | |
| 186 | return `${sha256Hash.substring(0, 8)}-${sha256Hash.substring(8, 12)}-4${sha256Hash.substring(13, 16)}-${v4variant}${sha256Hash.substring(17, 20)}-${sha256Hash.substring(20, 32)}`.toLowerCase(); |
| 187 | } |
| 188 | |
| 189 | function gitRevision(): string | undefined { |
| 190 | let gitRevision: string | undefined; |
no test coverage detected