locked
How to increase a character? RRS feed

  • Question

  • User1371138792 posted

    hi

     I have a string value "password" and i would like to increase each of the characters in the string by 2 position.

     for example, from "password" to "rcuuyqtf". Thanks

    Thursday, January 29, 2009 3:26 AM

Answers

  • User-1832689190 posted

    Hi,

        First use the namespace System.IO and do code as follows.

       private string increaseby2(Stream password ){

             byte[] buffer = new byte[password.Length];

             int n = password.Read(buffer, 0, buffer.Length);

              for(int i = 0; i<n; i++){

                          buffer[i] = (byte)buffer[i+2];

              }

              string passinc2 = Convert.ToString(buffer);

              return passinc2;

    }

    This may help you

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 29, 2009 5:58 AM
  • User533502567 posted

     It is a string value from a textbox and how do I convet it to a stream?

    Like this.. 

    byte[] bytes = System.Text.Encoding.ASCII.GetBytes(TextBox1.Text); 
    
    MemoryStream ms = new MemoryStream(bytes); 
    
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 29, 2009 8:51 PM
  • User1747761241 posted

    The old byte plus four ecryption.  I used to add four.

    loop the characters and x = asc(substring(password,x,1)) + 4

    something like that so a = 68.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 29, 2009 8:53 PM

All replies

  • User-1832689190 posted

    Hi,

        First use the namespace System.IO and do code as follows.

       private string increaseby2(Stream password ){

             byte[] buffer = new byte[password.Length];

             int n = password.Read(buffer, 0, buffer.Length);

              for(int i = 0; i<n; i++){

                          buffer[i] = (byte)buffer[i+2];

              }

              string passinc2 = Convert.ToString(buffer);

              return passinc2;

    }

    This may help you

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 29, 2009 5:58 AM
  • User1371138792 posted

    hi

     It is a string value from a textbox and how do I convet it to a stream? Thanks

    Thursday, January 29, 2009 8:39 PM
  • User533502567 posted

     It is a string value from a textbox and how do I convet it to a stream?

    Like this.. 

    byte[] bytes = System.Text.Encoding.ASCII.GetBytes(TextBox1.Text); 
    
    MemoryStream ms = new MemoryStream(bytes); 
    
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 29, 2009 8:51 PM
  • User1747761241 posted

    The old byte plus four ecryption.  I used to add four.

    loop the characters and x = asc(substring(password,x,1)) + 4

    something like that so a = 68.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 29, 2009 8:53 PM
  • User1371138792 posted

    thanks

     

    Thursday, January 29, 2009 11:12 PM