コード例 #1
0
        public RSAEncryptionService()
        {
            string        fullPathPrivate = FileManager.RootPath + "privatni_kljuc.txt";
            string        fullPathPublic  = FileManager.RootPath + "javni_kljuc.txt";
            RSAParameters parameters      = new RSAParameters();

            parameters.D       = Convert.FromBase64String(FileManager.ReadTextFile(fullPathPrivate));
            parameters.Modulus = Convert.FromBase64String(FileManager.ReadTextFile(fullPathPublic));
            RSAKeyProvider.ImportParams(parameters);
            rsaKey = RSAKeyProvider.ProvideKey();
        }
コード例 #2
0
ファイル: Startup.cs プロジェクト: MihaelAndel/os2-projekt
        private void UIActionCreateKeyFiles_Click(object sender, EventArgs e)
        {
            RSAKeyGenerator rsaGenerator = new RSAKeyGenerator(RSAKeyProvider.ProvideKey());
            AESKeyGenerator aesGenerator = new AESKeyGenerator(AESKeyProvider.ProvideKey());

            rsaGenerator.GenerateKeys();
            aesGenerator.GenerateKeys();

            FileManager.WriteTextToFile("javni_kljuc.txt", rsaGenerator.PublicKey);
            FileManager.WriteTextToFile("privatni_kljuc.txt", rsaGenerator.PrivateKey);
            FileManager.WriteTextToFile("tajni_kljuc.txt", aesGenerator.SecretKey);

            UIActionOpenEncryptionDialog.Enabled = true;
        }