} // End Function Crypt public static string GenerateKey() { System.Security.Cryptography.TripleDESCryptoServiceProvider objDESprovider = new System.Security.Cryptography.TripleDESCryptoServiceProvider(); objDESprovider.GenerateKey(); objDESprovider.GenerateIV(); byte[] bIV = objDESprovider.IV; byte[] bKey = objDESprovider.Key; return("IV: " + AES.ByteArrayToHexString(bIV) + System.Environment.NewLine + "Key: " + AES.ByteArrayToHexString(bKey)); } // End Function GenerateKey
} // End Function Crypt public static string GenerateKey() { byte[] bIV = null; byte[] bKey = null; using (System.Security.Cryptography.TripleDES des3 = System.Security.Cryptography.TripleDES.Create()) { des3.GenerateKey(); des3.GenerateIV(); bIV = des3.IV; bKey = des3.Key; } // End Using des3 return("IV: " + AES.ByteArrayToHexString(bIV) + System.Environment.NewLine + "Key: " + AES.ByteArrayToHexString(bKey)); } // End Function GenerateKey
} // End Function Crypt public static string GenerateKey() { string returnValue = null; using (System.Security.Cryptography.TripleDES des3 = System.Security.Cryptography.TripleDES.Create()) { des3.GenerateKey(); des3.GenerateIV(); byte[] bIV = des3.IV; byte[] bKey = des3.Key; returnValue = "IV: " + AES.ByteArrayToHexString(bIV) + System.Environment.NewLine + "Key: " + AES.ByteArrayToHexString(bKey); System.Array.Clear(bIV, 0, bIV.Length); bIV = null; System.Array.Clear(bKey, 0, bKey.Length); bKey = null; } return(returnValue); } // End Function GenerateKey