private static void Main(string[] args) { options = new OptionSet { { "h|help", "Show help", a => help = a != null }, { "p|password="******"The password to hash", a => password = a }, { "s|salt=", "Salt to use for hashing", a => salt = a }, { "i|iterations=", "Number of iterations (default: 1000)", (long a) => iterations = a }, { "o|outputBytes=", "Number of bytes to output (default: same as algorithm hash size)", (int a) => outputBytes = a }, { "a|algorithm=", "Algorithm (supported: MD5, SHA-1, SHA-256, SHA-384, SHA-512 - default: SHA-512)", a => algorithmName = a }, { "e|expected=", "Expected output formatted as a hex string (e.g. 'ab0937af...')", a => expected = a } }; try { ParseArguments(args); } catch (Exception e) { ShowError(e.Message); } try { using (var hasher = new PBKDF2DeriveBytes(prf, saltBytes, iterations)) { var result = hasher.GetBytes(outputBytes); string strResult = BitConverter.ToString(result).Replace("-", ""); if (expected != null) { Console.WriteLine(String.Equals(strResult, expected, StringComparison.OrdinalIgnoreCase) ? 1 : 0); } else { Console.WriteLine("{0}: {1}", algorithmName, strResult); } } } finally { prf.Dispose(); } }