Esempio n. 1
0
 protected void GenerateKeyCommand_Click(object sender, EventArgs e)
 {
     try
     {
         PublicKeyText.Text = AsymmetricEncryptionUtility.GenerateKey(KeyFileName);
         Response.Write("Key generated successfully!<br/>");
     }
     catch
     {
         Response.Write("Exception occured when encrypting key!");
     }
 }
Esempio n. 2
0
    protected void DecryptCommand_Click(object sender, EventArgs e)
    {
        // Check for encryption key
        if (!File.Exists(KeyFileName))
        {
            Response.Write("Missing encryption key. Please generate key!");
        }

        try
        {
            byte[] data = Convert.FromBase64String(EncryptedDataText.Text);
            ClearDataText.Text = AsymmetricEncryptionUtility.DecryptData(data, KeyFileName);
        }
        catch
        {
            Response.Write("Unable to decrypt data!");
        }
    }