diff --git a/src/app/features/shared/components/ui/static-pages/ciphering/ciphering.component.ts b/src/app/features/shared/components/ui/static-pages/ciphering/ciphering.component.ts index e29193fa..639d1fa0 100644 --- a/src/app/features/shared/components/ui/static-pages/ciphering/ciphering.component.ts +++ b/src/app/features/shared/components/ui/static-pages/ciphering/ciphering.component.ts @@ -25,7 +25,7 @@ export class CipheringComponent implements OnInit { public prem: number; public dico: string[]; public separatedCouples: any[]; - public codingMatrice: string = '2 3 5 8'; + public codingMatrice = '2 3 5 8'; private cipheredTextCIL: string; constructor() { @@ -193,8 +193,12 @@ export class CipheringComponent implements OnInit { * on entre une définition de matrice en écrivant 4 nombres dans un input * @param stringMatrix */ - convertStringToMatrix(stringMatrix: string) { - return stringMatrix.replace(',', ' ').replace(' ', ' ').slice(' '); + convertStringToMatrix(stringMatrix: string): number[] { + return stringMatrix + .replace(',', ' ') + .replace(' ', ' ') + .split(' ') + .map((elem) => parseInt(elem)); } /** @@ -281,8 +285,8 @@ export class CipheringComponent implements OnInit { } getEntropy(s) { - let sum = 0, - len = s.length; + let sum = 0; + const len = s.length; this.process(s, (k, f) => { const p = f / len; sum -= (p * Math.log(p)) / Math.log(2);