Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Encryption with tcpclient and tcplistner?

Encryption with tcpclient and tcplistner?

Scheduled Pinned Locked Moved C#
helpsysadminsecurityquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Druuler
    wrote on last edited by
    #1

    Hi! im new to encryption and would appreciatelittle help :) currently im using CryptoStream(RijandelManaged) with NetworkStream and it seems to work except that i dont get all the data right away. this is my current code:

    RijndaelManaged r = new RijndaelManaged();
    cryptoReadStream = new CryptoStream(netStream, r.CreateDecryptor(key, iv), CryptoStreamMode.Read);

    byte[] buffer= new byte[10000];
    cryptoReadStream.Read(buffer,0, buffer.Length);

    the problem is: 1.cryptoStream.Read blocks until 10000 bytes have been recived, unlike NetworkStream.Read which returns when theres is nothing more to read, this is a problem beacuse if the server only writes 10 bytes then ill have to wait forever before i can diplay the results.

    L 1 Reply Last reply
    0
    • D Druuler

      Hi! im new to encryption and would appreciatelittle help :) currently im using CryptoStream(RijandelManaged) with NetworkStream and it seems to work except that i dont get all the data right away. this is my current code:

      RijndaelManaged r = new RijndaelManaged();
      cryptoReadStream = new CryptoStream(netStream, r.CreateDecryptor(key, iv), CryptoStreamMode.Read);

      byte[] buffer= new byte[10000];
      cryptoReadStream.Read(buffer,0, buffer.Length);

      the problem is: 1.cryptoStream.Read blocks until 10000 bytes have been recived, unlike NetworkStream.Read which returns when theres is nothing more to read, this is a problem beacuse if the server only writes 10 bytes then ill have to wait forever before i can diplay the results.

      L Offline
      L Offline
      Leonardo Muzzi
      wrote on last edited by
      #2

      You can read it to an intermediate MemoryStream, still cryptografed, and after finishing reading you use the cryptoStream to decrypt the data.

      Regards, Leonardo Muzzi

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups