public void encryptUsingPublicKeyAndDoesNotDecryptUsingDifferentPrivateKey() { AsymmetricCryptography asymmetricCryptographyOther = new AsymmetricCryptography(); Encryption encryption = new Encryption(); byte[] encryptedText = encryption.encrypt(TEXT, asymmetricCryptography.getPublicKey()); encryption.decryption(encryptedText, asymmetricCryptographyOther.getPrivateKey()); }
public AuthenticationToken(T clientID, DateTime loginDate, DateTime expireDate, string xmlRSAKey) { ClientID = clientID; LoginDate = loginDate; ExpireDate = expireDate; if (!string.IsNullOrEmpty(xmlRSAKey)) { SignedData = AsymmetricCryptography.SignData(MakePayLoad(clientID, loginDate, expireDate), xmlRSAKey); } }
private void OptionEncryptRSA_Click(object sender, EventArgs e) { AsymmetricCryptography encrypterRSA = new AsymmetricCryptography(); encrypterRSA.GenerateKeys(); string contentToEncrypt = UploadedDocumentClass.GetFileContent(); string encrypted = encrypterRSA.EncryptDocumentRSA(contentToEncrypt); LoadingScreenForm loadScreen = new LoadingScreenForm(UploadedDocumentClass.GetFileName(), "RSA Encryption"); loadScreen.ShowDialog(); SaveToTxt("helpfile_rsa_encrypted", encrypted); outputScreen.Text = "Encrypted with RSA: \r\n" + encrypted; }
private void OptionDecryptRSA_Click(object sender, EventArgs e) { try { AsymmetricCryptography decrypterRSA = new AsymmetricCryptography(); string contentToDecrypt = UploadedDocumentClass.GetFileContent(); string decrypted = decrypterRSA.DecryptDocumentRSA(contentToDecrypt); LoadingScreenForm loadScreen = new LoadingScreenForm(UploadedDocumentClass.GetFileName(), "RSA Decryption"); loadScreen.ShowDialog(); SaveToTxt("helpfile_rsa_decrypted", decrypted); outputScreen.Text = "Decrypted with RSA: \r\n" + decrypted; } catch { MessageBox.Show("Document is not valid RSA encryption", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnGenerateForAppConfig_Click(object sender, EventArgs e) { TxtKey.Text = AsymmetricCryptography.CreateKey() .Replace("<", "<") .Replace(">", ">"); }
private void BtnGenerate_Click(object sender, EventArgs e) { TxtKey.Text = AsymmetricCryptography.CreateKey(); }
public bool IsValid(string xmlRSAKey, int tokenDuration) { string TempSignedData = AsymmetricCryptography.SignData(MakePayLoad(ClientID, LoginDate, ExpireDate), xmlRSAKey); return((TempSignedData == SignedData) && (LoginDate.AddMinutes(tokenDuration) < ExpireDate)); }