public async Task <string> writeCode(string docGuid, string code) { var password = Config["EmailConfirmKey"]; var gaiaToken = Config["GaiaToken"]; SimpleEncypt simpleEncypt = new SimpleEncypt(password); var existingCode = await getCode(docGuid); if (existingCode != "fail") { return("code already exists"); } string json = simpleEncypt.Encrypt(code); var client2 = new RestClient($"https://hub.blockstack.org/store/1PoZGGAuQ4yPj72TrXbG4pKbgB9tvCUqQ1/blockusign/{docGuid}.code.json"); var request2 = new RestRequest(Method.POST); request2.AddHeader("Content-Type", "application/json"); request2.AddHeader("Authorization", gaiaToken); request2.AddParameter("application/json", json, ParameterType.RequestBody); IRestResponse response2 = client2.Execute(request2); return("ok"); }
public async Task <string> getCode(string docGuid) { var password = Config["EmailConfirmKey"]; var gaiaToken = Config["GaiaToken"]; SimpleEncypt simpleEncypt = new SimpleEncypt(password); var client = new RestClient($"https://gaia.blockstack.org/hub/1PoZGGAuQ4yPj72TrXbG4pKbgB9tvCUqQ1/blockusign/{docGuid}.code.json"); var request = new RestRequest(Method.GET); IRestResponse response = await client.ExecuteAsync(request); if (response.IsSuccessful) { string encryptedData = response.Content; string decodedString = simpleEncypt.Decrypt(encryptedData); return(decodedString); } else { return("fail"); } }