Monday, 11 August 2014

Encrypt and decrypt the value or password.

// Encrypt and decrypt the value or password and save in database.



        con.Open();                        // connection open
        byte[] encData_byte = new byte[b.Length];                     // Encrypt the code and store in "b1" string variable
        encData_byte = System.Text.Encoding.UTF8.GetBytes(b);    // " b " is the value which you want to encrypt
        string b1 = Convert.ToBase64String(encData_byte);                  // Encrypted result

        System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();     // Encrypt the code and store in "b2" string 
        System.Text.Decoder utf8Decode = encoder.GetDecoder();
        byte[] todecode_byte = Convert.FromBase64String(b1);       // " b1 " is the value which you want to decrypt
        int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
        char[] decoded_char = new char[charCount];
        utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
        string b2= new String(decoded_char);           // Decrypted result
       
        string sq = "insert into testlogin values('" + a.ToString() + "','" + b.ToString() + "','" + b1.ToString() + "','" + b2.ToString() + "')";
        SqlCommand cmd = new SqlCommand(sq, con);
        cmd.ExecuteNonQuery();    // Execute the query

Thursday, 7 August 2014

Date Picker Calender

//  Date Picker Calender.

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script>
  $(function() {
    $( "#firstdate" ).datepicker();
    $( "#lastdate" ).datepicker();
  });
  </script>