title: Hill Cipher Encryption error with Javascript
body: <p>I am trying to implement Encryption with Hill Cipher, the code correctly encrypts the letters AC from ACT but the letter T is converted to U which is wrong. Can i know what is wrong in this code?</p>
  <p>I'm following the example given <a href="https://www.geeksforgeeks.org/hill-cipher/" rel="nofollow noreferrer">here</a></p>
  <p>Expected Output: ACT--&gt;POH<br>
  Current Output: ACT--&gt;POU</p>
  <pre class="lang-js prettyprint-override"><code>//Generates ASCII values of characters
  const generateAscii=(string)=&gt;{
      string=string.split('').map((value)=&gt;{
          return value.charCodeAt();
      });
      return string;
  };
  //Generates characters from ASCII value
  const generateChars=(ascii)=&gt;{
      ascii=ascii.map(value=&gt;String.fromCharCode(value));
      console.log(ascii);//Final Output generated here
  };
  //Encryption
  const encrypt=(input,key)=&gt;{
      let matrix=[];
      let cipherAscii=[];
      //Matrix creation
      for(let i in input){
          let values=key.splice(0,input.length);
          matrix.push(values);
      }
      //Matrix multiplication and encryption
      for (let i of matrix){
          let sum=0;
          for(let j in i){
              sum+=i[j]*input[j];
          }
          cipherAscii.push(((sum-65)%26)+65);
      }
      return cipherAscii;
  };
      let input='ACT';
      let key='GYBNQKURP';
      let encryptedValues;
      input=generateAscii(input)
      key=generateAscii(key);
      encryptedValues=encrypt(input,key);
      let encryptedText=generateChars(encryptedValues);
  
  </code></pre>