Thursday, 3 October 2013

request entity too large wcf

We can not send more than 64 kb data in WCF service.

to send more than default size.

just add below code in your wcf service web.config


 <bindings>  
    <basicHttpBinding>  
     <binding maxReceivedMessageSize="10485760">  
     </binding>  
    </basicHttpBinding>  
 </bindings>  

Monday, 23 September 2013

Encryption and Decryption code for php and .net

For .Net

 static string AES_Key = "AZjneNba78tqCuB8l8eQrXoAigmbjIwwngYfjEdnnLg=";//u can change this string - dont remove =  
     static string AES_IV = "Zty9weAigmbjIwwng3532JFbeRxGJzhl4Ymw9ry6SlQ=";//u can change this string - dont remove =  
     static void Main(string[] args)  
     {  
        Console.Write("Enter Ur Text-   ");  
       string InuptText = Console.ReadLine();  
       string ENcText = AES_encrypt(InuptText);  
       string DecText = AES_decrypt(ENcText);  
       //DecText = dynamic  
       Console.WriteLine("Encrypted Text-   " + ENcText);  
       Console.WriteLine("Decrypted Text-   " + DecText);  
       Console.ReadLine();  
     }  
     private static String AES_encrypt(String Input)  
     {  
       var aes = new RijndaelManaged();  
       aes.KeySize = 256;  
       aes.BlockSize = 256;  
       aes.Padding = PaddingMode.PKCS7;  
       aes.Key = Convert.FromBase64String(AES_Key);  
       aes.IV = Convert.FromBase64String(AES_IV);  
       var encrypt = aes.CreateEncryptor(aes.Key, aes.IV);  
       byte[] xBuff = null;  
       using (var ms = new MemoryStream())  
       {  
         using (var cs = new CryptoStream(ms, encrypt, CryptoStreamMode.Write))  
         {  
           byte[] xXml = Encoding.UTF8.GetBytes(Input);  
           cs.Write(xXml, 0, xXml.Length);  
         }  
         xBuff = ms.ToArray();  
       }  
       String Output = Convert.ToBase64String(xBuff);  
       return Output;  
     }  
     private static String AES_decrypt(String Input)  
     {  
       RijndaelManaged aes = new RijndaelManaged();  
       aes.KeySize = 256;  
       aes.BlockSize = 256;  
       aes.Mode = CipherMode.CBC;  
       aes.Padding = PaddingMode.PKCS7;  
       aes.Key = Convert.FromBase64String(AES_Key);  
       aes.IV = Convert.FromBase64String(AES_IV);  
       var decrypt = aes.CreateDecryptor();  
       byte[] xBuff = null;  
       using (var ms = new MemoryStream())  
       {  
         using (var cs = new CryptoStream(ms, decrypt, CryptoStreamMode.Write))  
         {  
           byte[] xXml = Convert.FromBase64String(Input);  
           cs.Write(xXml, 0, xXml.Length);  
         }  
         xBuff = ms.ToArray();  
       }  
       String Output = Encoding.UTF8.GetString(xBuff);  
       return Output;  
     }  


For php

 <?php  
 function addpadding($string, $blocksize = 32)  
 {  
   $len = strlen($string);  
   $pad = $blocksize - ($len % $blocksize);  
   $string .= str_repeat(chr($pad), $pad);  
   return $string;  
 }  
 function strippadding($string)  
 {  
   $slast = ord(substr($string, -1));  
   $slastc = chr($slast);  
   $pcheck = substr($string, -$slast);  
   if(preg_match("/$slastc{".$slast."}/", $string)){  
     $string = substr($string, 0, strlen($string)-$slast);  
     return $string;  
   } else {  
     return false;  
   }  
 }  
 function encrypt($string = "")  
 {  
   $key = base64_decode("jZjneNba78tqCuB8l8eQrXoAigmbjIwwngYfjEdnnLg=");  
   $iv = base64_decode("Uty9weAigmbjIwwng3532JFbeRxGJzhl4Ymw9ry6Slc=");   
   return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, addpadding($string), MCRYPT_MODE_CBC, $iv));  
 }  
 function decrypt($string = "")  
 {  
   $key = base64_decode("jZjneNba78tqCuB8l8eQrXoAigmbjIwwngYfjEdnnLg=");  
   $iv = base64_decode("Uty9weAigmbjIwwng3532JFbeRxGJzhl4Ymw9ry6Slc=");   
   $string = base64_decode($string);  
   return strippadding(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_CBC, $iv));  
 }  
 $aaa = encrypt("sai");  
 echo $aaa;  
 $sss = decrypt("UqInxPN3z8NjXWMLtlxlKORX7tcYTL2NnqyEsKm72UY=");  
 echo $sss;  
 ?>  


click here to download source code

Friday, 19 July 2013

we cannot truncate table without drop foreign key constraints

Yes, we can not truncate table without dropping foreign key constraints.

we can not truncate table if it is referenced by foreign key constraint, but we can delete all records in it.

Follow steps to truncate table -
1. Drop Constraints  (dropping constraint is necessary because Disable constraint wont work.)
2. Truncate Table
3. Add Constraints




Sunday, 14 July 2013

One day Rajmachi Picnic Trek - My trek experience with office friends.

Hi Friends, 

Rajmachi place is near pune in maharahstra. Our trip was one day trip but i ll suggest please go for 1 night stay.

We were 21 peoples including 8 girls.

I am not writting much more because i know everyone is interested in seeing pics. 

How to go -There is two way to go Rajmachi. 
From Karjat - Kondivade Village - 8kms to reach Rajmachi - approx 3-4hrs - Jungle way full slope - not difficult but not very easy. 
From Lonavala - Delta Company. - 18Kms to reach Rajmachi - approx 6-7hrs - very easy way.
I will always suggest go from Karjat way, if u love trek.

U can get a sumo-pvt vehicle for dhangarwadi to delta company almost 10-12kms, - towords lonavala

Find below contact numbers for lunch-dinner and sumo private vehicle - 
Nisarg Shrushti Hotel - Contact Person Shantaram Umbare. 
9850271060

Shantaram Umbare is gavakari of rajmachi who stayed in rajmachi. so you want any more detail contact him.



Rajmachi is very good place for picnic.

Every trekker boys/girl must visit this place at least once in life.

 

View From Bottom Kondivade- Karjat Gaon.



First waterfall


























See foot step.





View from top middle.





























Nisarg Shrushti Hotel


Veg Thali


Non-Veg Thali

























































Thanx to all my friends who made this picnic enjoyable.
Nandu, Vaibhav, Mangesh, Vishal, Mayur, Suniket, Saurav, Kartik, Swapnil, Deepak
Neeta T, Neeta B, Gauri, Lalita, Minal, Durga
Manoj, Jayashree, Ganesh, Pragati

Friday, 28 June 2013

Why we used ref keyword ?

Suppose you have to get the value that has changed inside function. to get that changed value outside the function then use ref keyword.

1. This should be used when you re-instantiate the object inside function. 

2. This should be used, if your object is string or any value type Object.

Class1 ObjClass = new Class1();
ObjClass.StrA = 55;
GetA(ref ObjClass);
int ss = ObjClass.StrA; //ss value is 99 after re-instatiate inside function

private void GetA(Class1 ObjClass)
{
   ObjClass = new Class1();
   ObjClass.StrA = 99;
}

Thursday, 27 June 2013

Do Audit Trail by triggers in MS-SQL

I have written SQL dynamic script which will create tirggers in your database. you have to just mention table name.
if your audit log table column would different then do some customization in query as per your requirement.

columns of audit log table

 mode        -     Insert/Update  
 insertedon    -     Current date  
 tblname      -    Table Name       
 colname      -    Coulumn Name  
 id           -    Primary Key Of Table  
 oldval        -    Old Value before update  
 newval       -    New Value after Update or Insert  
 Ip          -    Ip Address of table  


Donwload Audit Trail txt