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. Visual Basic
  4. cryptostream

cryptostream

Scheduled Pinned Locked Moved Visual Basic
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.
  • W Offline
    W Offline
    WhiteGirl23
    wrote on last edited by
    #1

    Hi, I want to make an encryptation to a string but the result to be places in a textbox. I tried the cryptostream class but it work only with stream. thanks

    K 1 Reply Last reply
    0
    • W WhiteGirl23

      Hi, I want to make an encryptation to a string but the result to be places in a textbox. I tried the cryptostream class but it work only with stream. thanks

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      You should be able to write out the stream to a byte array and then convert the byte array to a string. Here are some methods I have used, sorry they are in C# They should be easy to re-write in vb.net

      public static String MemoryStreamToString(MemoryStream p_ms)
      {
      return MemoryStreamToString(p_ms, Encoding.Default);
      }
      public static String MemoryStreamToString(MemoryStream p_ms, Encoding p_encoding)
      {
      return ByteArrayToString(p_ms.GetBuffer(), p_encoding);
      }

      public static MemoryStream StringToMemoryStream(String p_string)
      {
      return StringToMemoryStream(p_string, Encoding.Default);
      }
      public static MemoryStream StringToMemoryStream(String p_string, Encoding p_encoding)
      {
      return new MemoryStream(StringToByteArray(p_string, p_encoding));
      }

      public static Byte[] StringToByteArray(string p_str)
      {
      return StringToByteArray(p_str, Encoding.Default);
      }
      public static Byte[] StringToByteArray(string p_str, Encoding p_encoding)
      {
      return p_encoding.GetBytes(p_str);
      }

      public static string ByteArrayToString(byte[] p_byteArray)
      {
      return ByteArrayToString(p_byteArray, Encoding.Default);
      }
      public static string ByteArrayToString(byte[] p_byteArray, Encoding p_encoding)
      {
      int numberOfBytes = p_byteArray.Length;
      return p_encoding.GetString(p_byteArray, 0, numberOfBytes);
      }

      Hope that helps. Ben

      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