Skip to content

Instantly share code, notes, and snippets.

@jsakamoto
Last active December 17, 2015 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsakamoto/5532539 to your computer and use it in GitHub Desktop.
Save jsakamoto/5532539 to your computer and use it in GitHub Desktop.
if (args.Length == 2 && args[1] == "-f")
{
sha1(File.ReadAllBytes(args[2]));
}
else if (args.Length == 1)
{
sha1(Encoding.ASCII.GetBytes(args[1]));
}
else if (args.Length == 0)
{
sha1(Encoding.ASCII.GetBytes(Console.ReadToEnd());
}
else
{
throw new Exception("error");
}
match args with
| [| _; "-f"; path |] -> sha1(File.ReadAllBytes(path))
| [| _; arg |] -> sha1(Encoding.ASCII.GetBytes(arg))
| [| _ |] -> sha1(Encoding.ASCII.GetBytes(Console.ReadToEnd())
| _ -> failwith("error")
match args with
| [| _; "-f"; path |] -> path |> File.ReadAllBytes |> sha1
| [| _; arg |] -> arg |> Encoding.ASCII.GetBytes |> sha1
| [| _ |] -> Console.ReadToEnd() |> Encoding.ASCII.GetBytes |> sha1
| _ -> failwith("error")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment