@@ -127,8 +127,8 @@ <h3 id="methods">
127127
128128 < tr >
129129 < td class ="col-md-4 ">
130- < div class ="io-line "> Defined in < a href ="" data-line ="16 "
131- class ="link-to-prism "> projects/lib/src/token-validation/hash-handler.ts:16 </ a > </ div >
130+ < div class ="io-line "> Defined in < a href ="" data-line ="33 "
131+ class ="link-to-prism "> projects/lib/src/token-validation/hash-handler.ts:33 </ a > </ div >
132132 </ td >
133133 </ tr >
134134
@@ -207,8 +207,8 @@ <h3 id="methods">
207207
208208 < tr >
209209 < td class ="col-md-4 ">
210- < div class ="io-line "> Defined in < a href ="" data-line ="36 "
211- class ="link-to-prism "> projects/lib/src/token-validation/hash-handler.ts:36 </ a > </ div >
210+ < div class ="io-line "> Defined in < a href ="" data-line ="60 "
211+ class ="link-to-prism "> projects/lib/src/token-validation/hash-handler.ts:60 </ a > </ div >
212212 </ td >
213213 </ tr >
214214
@@ -275,8 +275,8 @@ <h3 id="methods">
275275
276276 < tr >
277277 < td class ="col-md-4 ">
278- < div class ="io-line "> Defined in < a href ="" data-line ="28 "
279- class ="link-to-prism "> projects/lib/src/token-validation/hash-handler.ts:28 </ a > </ div >
278+ < div class ="io-line "> Defined in < a href ="" data-line ="52 "
279+ class ="link-to-prism "> projects/lib/src/token-validation/hash-handler.ts:52 </ a > </ div >
280280 </ td >
281281 </ tr >
282282
@@ -332,28 +332,52 @@ <h3 id="methods">
332332 < pre class ="line-numbers compodoc-sourcecode "> < code class ="language-typescript "> import { Injectable } from '@angular/core';
333333
334334import { factory } from './js-sha256';
335-
336335const sha256 = factory();
337336
337+ import fsha256 from 'fast-sha256';
338+
338339/**
339340 * Abstraction for crypto algorithms
340341 */
341342export abstract class HashHandler {
342343 abstract calcHash(valueToHash: string, algorithm: string): Promise<string>;
343344}
344345
346+ function decodeUTF8(s) {
347+ if (typeof s !== 'string') throw new TypeError('expected string');
348+ var i,
349+ d = s,
350+ b = new Uint8Array(d.length);
351+ for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
352+ return b;
353+ }
354+
355+ function encodeUTF8(arr) {
356+ var i,
357+ s = [];
358+ for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
359+ return s.join('');
360+ }
361+
345362@Injectable()
346363export class DefaultHashHandler implements HashHandler {
347364 async calcHash(valueToHash: string, algorithm: string): Promise<string> {
348365 // const encoder = new TextEncoder();
349366 // const hashArray = await window.crypto.subtle.digest(algorithm, data);
350367 // const data = encoder.encode(valueToHash);
351368
352- const hashArray = (sha256 as any).array(valueToHash);
353- // const hashString = this.toHashString(hashArray);
354- const hashString = this.toHashString2(hashArray);
369+ // const fhash = fsha256(valueToHash);
370+
371+ const candHash = encodeUTF8(fsha256(decodeUTF8(valueToHash)));
372+
373+ // const hashArray = (sha256 as any).array(valueToHash);
374+ // // const hashString = this.toHashString(hashArray);
375+ // const hashString = this.toHashString2(hashArray);
376+
377+ // console.debug('hash orig - cand', candHash, hashString);
378+ // alert(1);
355379
356- return hashString ;
380+ return candHash ;
357381 }
358382
359383 toHashString2(byteArray: number[]) {
0 commit comments