Yenc Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Extremest

    Yenc Help

    Does anyone know how to decode a yenc encoded file? I have created a
    decoder that seems to work great for text. Now i am trying to create
    another one for images and I can't get it to work. I have changed the
    encoding on mine and that didn't work and then I tried the only 2 open
    source ones I can Find. It is driving me nuts.
  • Peter Duniho

    #2
    Re: Yenc Help

    On Sat, 09 Feb 2008 21:27:18 -0800, Extremest <admin@binindex .netwrote:
    Does anyone know how to decode a yenc encoded file? I have created a
    decoder that seems to work great for text. Now i am trying to create
    another one for images and I can't get it to work. I have changed the
    encoding on mine and that didn't work and then I tried the only 2 open
    source ones I can Find. It is driving me nuts.
    It seems to me that "the horse's mouth", so to speak, would be your best
    bet:


    I don't think this newsgroup is a good place for general "yenc-specific"
    discussions, but if you've got an issue implementing the format decoder
    that relates specifically to your use of C# or .NET, please feel free to
    post those questions here.

    Pete

    Comment

    • Extremest@extremest.com

      #3
      Re: Yenc Help

      I think i have the decode part right. The problem seems to maybe be
      with the encoding of the string or something. Was wanting some help
      on that part of it. The rest should be ok. I have looked at quite
      a few decoders and they all do the same thing. My problem is the
      encoding of the stream or something.

      Comment

      • =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=

        #4
        Re: Yenc Help

        This is extremely vague. If you want to post a "short but complete" code
        sample, being very specific about the exact problem with appropriate code
        comments, you can probably expect to get some help.
        -- Peter
        Site: http://www.eggheadcafe.com
        UnBlog: http://petesbloggerama.blogspot.com
        MetaFinder: http://www.blogmetafinder.com


        "Extremest" wrote:
        I think i have the decode part right. The problem seems to maybe be
        with the encoding of the string or something. Was wanting some help
        on that part of it. The rest should be ok. I have looked at quite
        a few decoders and they all do the same thing. My problem is the
        encoding of the stream or something.
        >
        >

        Comment

        • Extremest@extremest.com

          #5
          Re: Yenc Help

          Ok here is my function that goes through the data. I have gotten it
          really close just don't know if there is some encoding on a stream
          that I am doing wrong or what. Code is rough. Want to get it
          working then will clean it up.

          static void collect()
          {
          for (int x = 0; x < msg_ids.Count; x++)
          {
          Connect();
          byte[] buff = new byte[BUFFERSIZE];//buffer for
          decoded data.
          NetworkStream networkStream = tcpClient.GetSt ream
          ();//nntp connection.
          StreamReader reader = new StreamReader
          (networkStream, Encoding.Defaul t);//reader for nntp connection.
          StreamWriter writer = new StreamWriter
          (networkStream) ;//writer for nntp connection.
          writer.AutoFlus h = true;
          int bufferLength = 0;//where we are in the buff
          array.
          int filelength = 0;//Length of the file from the
          header.
          string id = msg_ids[x] as string;//The msg_id for
          the article.
          string line;//Line that is read from the connection.
          string fileName;//Name of the file from the header.
          id = "body " + id;//build article request.
          id = id.Trim();
          writer.WriteLin e(id);//write article request to nntp
          line = reader.ReadLine ();//read response from nntp
          /*Loop until it finds the beginning of the yenc
          data*/
          while (reader.Peek() >= 0 && line != null && !
          line.StartsWith ("=ybegin") &&
          !line.StartsWit h("begin 644"))
          {
          line = reader.ReadLine ();
          if (line == ".")
          {
          break;
          }
          }
          if (line.StartsWit h("begin 644"))//Not implemented
          yet.
          {
          Disconnect();
          continue;
          }
          else
          {
          if (line == null || line == ".")
          {
          Disconnect();
          continue;
          }
          fileName = parseForName(li ne);//get filename
          from the header.
          string tempsize = parseForString( line,
          "size");//get size from the header.
          Console.WriteLi ne(tempsize);
          filelength = int.Parse(temps ize);
          if (fileName == null)//not valid header.
          {
          Disconnect();
          continue;
          }
          String partNo = parseForString( line, "part");//
          get part # from header.
          if (partNo != null)//check and see if there are
          more parts or to remove the line from the code.
          {
          while (line != null && !line.StartsWit h
          ("=ypart"))
          {
          line = reader.ReadLine ();
          Console.WriteLi ne("--{0}--", line);
          }
          if (line == null)
          throw new IOException("Er ror while
          handling a multipart reader. Could not locate line starting with
          \"=ypart\"." );
          }
          // Decode the file
          line = reader.ReadLine ();//read first line of
          encoded data.
          while (line != null && !line.StartsWit h
          ("=yend"))//will go to end of encoded data.
          {
          for (int lcv = 0; lcv < line.Length;
          lcv++)//go through line by char.
          {
          if (line[lcv] == '=')//find escape char.
          {
          lcv++;
          if (line[lcv] < 106)//used for the
          mod
          {
          int ts = 106 - line[lcv];
          ts = 256 - ts;
          buff[bufferLength] = (byte) ts;
          bufferLength++;
          }
          else
          {
          buff[bufferLength] = (byte)
          ((line[lcv] - 64) - 42);
          bufferLength++;
          }
          }
          else
          {
          if (line[lcv] < 42)//used for the
          mod
          {
          int ts = 42 - line[lcv];
          ts = 256 - ts;
          buff[bufferLength] = (byte) ts;
          bufferLength++;
          }
          else
          {
          buff[bufferLength] = (byte)
          (line[lcv] - 42);
          bufferLength++;
          }
          }
          }
          line = reader.ReadLine ();//read next line
          for the loop.
          }
          }
          if (bufferLength 0)//check to see if we decoded
          anything if so then write it to a file.
          {
          FileStream fs = File.Create(fil eName);
          BinaryWriter bw = new BinaryWriter
          (fs,Encoding.De fault);
          bw.Write(buff,0 ,filelength);
          bw.Close();
          fs.Close();
          }
          }
          }

          Comment

          • Peter Duniho

            #6
            Re: Yenc Help

            On Mon, 11 Feb 2008 10:29:56 -0800, Extremest@extre mest.com <Extremest>
            wrote:
            Ok here is my function that goes through the data. I have gotten it
            really close just don't know if there is some encoding on a stream
            that I am doing wrong or what. Code is rough. Want to get it
            working then will clean it up.
            All due respect, it's not really clear what you expect. Are you thinking
            that someone will read through your code and discover an error in the
            basic logic of your yenc implementation? If so, I think you're being too
            optimistic.

            If there is something specific to how you're using C# and/or .NET in your
            implementation that you have a question about, this is an appropriate
            forum. But I wouldn't say that it's very likely you're going to find
            anyone who would just review your code for random bugs, especially for a
            task of relatively marginal popularity like a yenc implementation.

            If you expect help here, you need to be asking more specific questions
            than just "here's my code, what's wrong with it?"

            Pete

            Comment

            • Extremest@extremest.com

              #7
              Re: Yenc Help

              I was mainly asking if anyone knew if the encoding of the streams
              was right? I have managed to get uudecoding done with those streams
              using php in c# and when I try to do yenc decoding a come up with
              only a couple of bytes that are not right when comparing to the same
              picture already downloaded with another program.

              Comment

              Working...