code: public static BigInteger encodeStringToInteger(String str) {
          byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
          byte[] res;
          if ((bytes[0] & 0b1000_0000) >> 7 == 1) {
              res = new byte[bytes.length + 1];
              res[0] = 0;
              System.arraycopy(bytes, 0, res, 1, bytes.length);
          } else {
              res = bytes;
          }
          BigInteger r = new BigInteger(res);
          assert r.compareTo(BigInteger.ZERO) > 0;
          return r;
      }
docs: Encode any valid Unicode string to integer.
  
  @param str string to encode as integer.
  @return integer representation of the secret string.