Пример #1
0
        private void UIActionAsymEncrypt_Click(object sender, EventArgs e)
        {
            string fileContent       = FileManager.ReadTextFile(pathToFile);
            RSAEncryptionService rsa = new RSAEncryptionService();
            string encryptedContent  = rsa.EncryptText(fileContent);

            FileManager.WriteTextToFile("asimetricna-enkripcija.txt", encryptedContent);

            MessageBox.Show(encryptedContent);
        }
Пример #2
0
        private void UIActionAsymDecrypt_Click(object sender, EventArgs e)
        {
            RSAEncryptionService rsa = new RSAEncryptionService();

            string fullPath         = FileManager.RootPath + "asimetricna-enkripcija.txt";
            string encryptedContent = FileManager.ReadTextFile(fullPath);

            string decryptedContent = rsa.DecryptText(encryptedContent);

            FileManager.WriteTextToFile("asimetricna-dekripcija.txt", decryptedContent);

            MessageBox.Show(decryptedContent);
        }
Пример #3
0
        private void UIActionCreateSignature_Click(object sender, EventArgs e)
        {
            string fileContent       = FileManager.ReadTextFile(pathToFile);
            RSAEncryptionService rsa = new RSAEncryptionService();

            byte[] signedBytes = rsa.SignData(fileContent);

            signature = signedBytes;

            string signedContent = Convert.ToBase64String(signedBytes);

            FileManager.WriteTextToFile("potpis.txt", signedContent);

            MessageBox.Show(signedContent);
        }
Пример #4
0
        private void UIActionVerifySignature_Click(object sender, EventArgs e)
        {
            string pathToData = pathToFile;

            string data = FileManager.ReadTextFile(pathToData);

            byte[] dataBytes = Encoding.UTF8.GetBytes(data);

            RSAEncryptionService rsa = new RSAEncryptionService();

            if (rsa.VerifySignature(dataBytes, signature) == true)
            {
                MessageBox.Show("Potpis je valjan!");
            }
            else
            {
                MessageBox.Show("Potpis nije valjan!");
            }
        }