code: function pkcs1pad2(s, n) {
          if (n < s.length + 11) { // TODO: fix for utf-8
              console.error("Message too long for RSA");
              return null;
          }
          var ba = new Array();
          var i = s.length - 1;
          while (i >= 0 && n > 0) {
              var c = s.charCodeAt(i--);
              if (c < 128) { // encode using utf-8
                  ba[--n] = c;
              }
              else if ((c > 127) && (c < 2048)) {
                  ba[--n] = (c & 63) | 128;
                  ba[--n] = (c >> 6) | 192;
              }
              else {
                  ba[--n] = (c & 63) | 128;
                  ba[--n] = ((c >> 6) & 63) | 128;
                  ba[--n] = (c >> 12) | 224;
              }
          }
          ba[--n] = 0;
          var rng = new SecureRandom();
          var x = new Array();
          while (n > 2) { // random non-zero pad
              x[0] = 0;
              while (x[0] == 0) rng.nextBytes(x);
              ba[--n] = x[0];
          }
          ba[--n] = 2;
          ba[--n] = 0;
          return new BigInteger(ba);
      }
docs: PKCS#1 (type 2, random) pad input string s to n bytes, and return a bigint