Files
intro-to-docker/02-Phoenix/Hashr/Controllers/ValuesController.cs
2017-01-13 18:05:42 -05:00

33 lines
887 B
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Routing;
using System.Security.Cryptography;
namespace Hashr.Controllers
{
public class ValuesController : Controller
{
[HttpGetAttribute]
[Route("")]
public string hashr()
{
return "hashr yo whoop whoop!";
}
// POST api/values
[HttpPost]
[Route("hashme")]
public async Task<string> HashMe()
{
using(var memstream = new MemoryStream())
using(var sha = SHA256.Create())
{
await this.Request.Body.CopyToAsync(memstream);
return System.Text.Encoding.ASCII.GetString(sha.ComputeHash(memstream.ToArray()));
}
}
}
}