Ejemplo n.º 1
0
        public static async Task <HttpResponseMessage> EncryptDecryptAsync(
            [HttpTrigger("GET")] HttpRequestMessage request,
            [KeyVaultCrypto("AKey", "RSA-OAEP")] ICryptoOperationsAsync crypto,
            TraceWriter log)
        {
            var cipher = await crypto.EncryptAsync(Encoding.UTF8.GetBytes("this is test plaintext"));

            var check = Encoding.UTF8.GetString(await crypto.DecryptAsync(cipher));

            return(request.CreateResponse(HttpStatusCode.OK, $"{check}"));
        }
Ejemplo n.º 2
0
        public static async Task <HttpResponseMessage> SignVerifyAsync(
            [HttpTrigger("GET")] HttpRequestMessage request,
            [KeyVaultCrypto("AKey", "RS256")] ICryptoOperationsAsync crypto,
            TraceWriter log)
        {
            var hasher = new SHA256CryptoServiceProvider();
            var digest = hasher.ComputeHash(Encoding.UTF8.GetBytes("this is test plaintext"));
            var sig    = await crypto.SignAsync(digest);

            var check = await crypto.VerifyAsync(digest, sig);

            return(request.CreateResponse(HttpStatusCode.OK, $"{check}"));
        }