Pular para o conteúdo

Exemplos

Abaixo temos alguns exemplos de implementação da integração com AnnA Web Services

string decKey = "DECRYPTION_KEY";
string encKey = "ENCRYPTION_KEY";
string IV = form.Get("ANNAEXEC"); // IV that AnnA will send to you
// Get post variables values (if any)
string anotherVar = Decrypt3DES(form.Get("AnotherVar"), decKey, IV);
string containers = JsonConvert.SerializeObject(
new List<object>
{
new
{
PropName = "Container001",
PropValue = new List<object>
{
new
{
PropName = "Type",
PropValue = "MESSAGE"
},
new
{
PropName = "Phrase",
PropValue = "The value of AnotherVar is: " + anotherVar
}
}
}
}
);
// Generate new IV
TripleDESCryptoServiceProvider cryptoServiceProvider = new TripleDESCryptoServiceProvider();
cryptoServiceProvider.GenerateIV();
string newBase64IV = Convert.ToBase64String(cryptoServiceProvider.IV);
string encryptedContainers = Encrypt3DES(containers, encKey, newBase64IV);
string newEncryptedBase64IV = Encrypt3DES(newBase64IV, decKey, IV);
var response = new HttpResponseMessage(HttpStatusCode.OK);
response.Content = new StringContent(encryptedContainers + IV + newEncryptedBase64IV, Encoding.UTF8, "text/plain");
return response;