IdentifiantMot de passe
Loading...
Mot de passe oubli� ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les r�ponses en temps r�el, voter pour les messages, poser vos propres questions et recevoir la newsletter

VC++ .NET Discussion :

securit� sous visual c++


Sujet :

VC++ .NET

Vue hybride

Message pr�c�dent Message pr�c�dent   Message suivant Message suivant
  1. #1
    Membre �clair�
    Inscrit en
    Avril 2007
    Messages
    326
    D�tails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 326
    Par d�faut securit� sous visual c++
    je travaille sous visual studio 2005 et comme language visual c++
    je veux cr�er un application qui s�curise des fichiers

    donc j ai commenc� par ajout� dans le menu un boutton" protect" et ce que je veux une fois je clik dessus, il m affiche une boite de dialog pour entrer un login et un pass puis en fonction de ca voir s il peut rendre le fichier prot�g�

    est ce que quelqu un peux m aider?
    est ce qu il ya des classes d�ja existentes qui font ceci ? si oui comment ?

    merci

  2. #2
    R�dacteur
    Avatar de nico-pyright(c)
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    6 414
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 6 414
    Par d�faut
    tu veux crypter le fichier ? en fonction d'une phrase ?
    le framework.net permet cela assez facilement, peux-tu l'utiliser ?

  3. #3
    Membre �clair�
    Inscrit en
    Avril 2007
    Messages
    326
    D�tails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 326
    Par d�faut d�butant!
    comment pourrais je le crypter .. peux tu detailler un peu plus

  4. #4
    R�dacteur
    Avatar de nico-pyright(c)
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    6 414
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 6 414
    Par d�faut
    est-ce que tu veux utiliser le framework.net ou pas ? ca simplifierai les choses

  5. #5
    Membre �clair�
    Inscrit en
    Avril 2007
    Messages
    326
    D�tails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 326
    Par d�faut
    dis moi comment ?

  6. #6
    Membre �clair�
    Inscrit en
    Avril 2007
    Messages
    326
    D�tails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 326
    Par d�faut
    oui je veux utiliser si c plus simple !

  7. #7
    Candidat au Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    4
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 4
    Par d�faut
    Citation Envoy� par ryoussef19
    je travaille sous visual studio 2005 et comme language visual c++
    je veux cr�er un application qui s�curise des fichiers

    donc j ai commenc� par ajout� dans le menu un boutton" protect" et ce que je veux une fois je clik dessus, il m affiche une boite de dialog pour entrer un login et un pass puis en fonction de ca voir s il peut rendre le fichier prot�g�

    est ce que quelqu un peux m aider?
    est ce qu il ya des classes d�ja existentes qui font ceci ? si oui comment ?

    merci

  8. #8
    Candidat au Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    4
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 4
    Par d�faut Vista
    Est-ce que tu travaille ton visual c++ 2005 sous vista..... rien de ta demande mais moi je suis sur vista et et je me suis procurer ce logiciel et il ne fonctionne pas sous vista
    CIAO
    ti-guy




    Citation Envoy� par ryoussef19
    je travaille sous visual studio 2005 et comme language visual c++
    je veux cr�er un application qui s�curise des fichiers

    donc j ai commenc� par ajout� dans le menu un boutton" protect" et ce que je veux une fois je clik dessus, il m affiche une boite de dialog pour entrer un login et un pass puis en fonction de ca voir s il peut rendre le fichier prot�g�

    est ce que quelqu un peux m aider?
    est ce qu il ya des classes d�ja existentes qui font ceci ? si oui comment ?

    merci

  9. #9
    Membre �clair�
    Inscrit en
    Avril 2007
    Messages
    326
    D�tails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 326
    Par d�faut
    non c pas sur vista ...c sur windows xp

  10. #10
    Membre �clair�
    Inscrit en
    Avril 2007
    Messages
    326
    D�tails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 326
    Par d�faut
    j'ai recommenc� un autre projet(ca marche tjrs pas ) avec une seule form o� l utilisateur rentre son fichier (� crypter) et son mon de passe qui va servir pour crypter
    une fois il clik sur ok le fichier sera crypt�
    voici mon code ...
    Fichiers attach�s Fichiers attach�s

  11. #11
    Membre �clair�
    Inscrit en
    Avril 2007
    Messages
    326
    D�tails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 326
    Par d�faut
    il me met comme erreur dans le aes.cpp

    API call 'ImportFile' failed :le systeme ne peut pas trouver "stdafx.h"

  12. #12
    Membre �clair�
    Inscrit en
    Avril 2007
    Messages
    326
    D�tails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 326
    Par d�faut
    maintenant j'ai les methodes crypter et decrypter et generate key directement dans ma form1 pour que je puisse utiliser sans probl�mes

    voici le code de la form1:

    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
     
    #pragma once
     
     
    namespace crypt_file {
     
    	using namespace System;
    	using namespace System::ComponentModel;
    	using namespace System::Collections;
    	using namespace System::Windows::Forms;
    	using namespace System::Data;
    	using namespace System::Drawing;
     
                 using namespace System::Text;
                 using namespace System::Security::Cryptography;
                 using namespace System::IO;
     
    	/// <summary>
    	/// Summary for Form1
    	///
    	/// WARNING: If you change the name of this class, you will need to change the
    	///          'Resource File Name' property for the managed resource compiler tool
    	///          associated with all .resx files this class depends on.  Otherwise,
    	///          the designers will not be able to interact properly with localized
    	///          resources associated with this form.
    	/// </summary>
    	public ref class Form1 : public System::Windows::Forms::Form
    	{
    	public:
    		Form1(void)
    		{
    			InitializeComponent();
    			//
    			//TODO: Add the constructor code here
    			//
    		}
     
    	protected:
    		/// <summary>
    		/// Clean up any resources being used.
    		/// </summary>
    		~Form1()
    		{
    			if (components)
    			{
    				delete components;
    			}
    		}
    	private: System::Windows::Forms::Button^  button1;
    	protected: 
    	private: System::Windows::Forms::Label^  label1;
    	private: System::Windows::Forms::TextBox^  textBox1;
    	private: System::Windows::Forms::TextBox^  textBox2;
    	private: System::Windows::Forms::Label^  label2;
     
    	private:
    		/// <summary>
    		/// Required designer variable.
    		/// </summary>
    		System::ComponentModel::Container ^components;
     
    #pragma region Windows Form Designer generated code
    		/// <summary>
    		/// Required method for Designer support - do not modify
    		/// the contents of this method with the code editor.
    		/// </summary>
    		void InitializeComponent(void)
    		{
    			this->button1 = (gcnew System::Windows::Forms::Button());
    			this->label1 = (gcnew System::Windows::Forms::Label());
    			this->textBox1 = (gcnew System::Windows::Forms::TextBox());
    			this->textBox2 = (gcnew System::Windows::Forms::TextBox());
    			this->label2 = (gcnew System::Windows::Forms::Label());
    			this->SuspendLayout();
    			// 
    			// button1
    			// 
    			this->button1->Location = System::Drawing::Point(103, 225);
    			this->button1->Name = L"button1";
    			this->button1->Size = System::Drawing::Size(79, 25);
    			this->button1->TabIndex = 0;
    			this->button1->Text = L"OK";
    			this->button1->UseVisualStyleBackColor = true;
    			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
    			// 
    			// label1
    			// 
    			this->label1->AutoSize = true;
    			this->label1->Location = System::Drawing::Point(53, 55);
    			this->label1->Name = L"label1";
    			this->label1->Size = System::Drawing::Size(20, 13);
    			this->label1->TabIndex = 1;
    			this->label1->Text = L"file";
    			// 
    			// textBox1
    			// 
    			this->textBox1->Location = System::Drawing::Point(56, 162);
    			this->textBox1->Name = L"textBox1";
    			this->textBox1->Size = System::Drawing::Size(170, 20);
    			this->textBox1->TabIndex = 2;
    			// 
    			// textBox2
    			// 
    			this->textBox2->Location = System::Drawing::Point(56, 81);
    			this->textBox2->Name = L"textBox2";
    			this->textBox2->Size = System::Drawing::Size(170, 20);
    			this->textBox2->TabIndex = 3;
    			// 
    			// label2
    			// 
    			this->label2->AutoSize = true;
    			this->label2->Location = System::Drawing::Point(53, 122);
    			this->label2->Name = L"label2";
    			this->label2->Size = System::Drawing::Size(29, 13);
    			this->label2->TabIndex = 4;
    			this->label2->Text = L"pass";
    			// 
    			// Form1
    			// 
    			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    			this->ClientSize = System::Drawing::Size(292, 270);
    			this->Controls->Add(this->label2);
    			this->Controls->Add(this->textBox2);
    			this->Controls->Add(this->textBox1);
    			this->Controls->Add(this->label1);
    			this->Controls->Add(this->button1);
    			this->Name = L"Form1";
    			this->Text = L"Form1";
    			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
    			this->ResumeLayout(false);
    			this->PerformLayout();
     
    		}
    #pragma endregion
    	private : String ^val1;
    	private : String ^val2;
    	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
     
    				 val1 = "Saisir un pass ...";
    				 val2 = "Saisir un fichier";
    				 textBox1->Text = val1;
    				 textBox2->Text = val2;
    			 }
     
     
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
     
    			 StreamReader ^sr = gcnew StreamReader(this->GetValue2());
    			 StreamWriter ^sw = gcnew StreamWriter("Desktop\text0.doc");
     
    				 try
    	{
    		String ^a = Crypter(sr->ReadToEnd(), this->GetValue1());
    		sw->Write(a);
    	}
    	catch (Exception^)
    	{
    	}
    	finally
    	{
    		sr->Close();
    		sw->Close();
    	}
     
     
    		 }
     public:
    		String ^GetValue1()
    		{
    			return val1;
    		}
    public:
    		String ^GetValue2()
    		{
    			return val2;
    		}
     
    public:
    	void GenerateKey(String ^SecretPhrase, array<unsigned char> ^&Key, array<unsigned char> ^&IV)
    {
    	array<unsigned char> ^bytePhrase = Encoding::ASCII->GetBytes(SecretPhrase);
    	SHA384Managed ^sha384 = gcnew SHA384Managed();
    	sha384->ComputeHash(bytePhrase);
    	array<unsigned char> ^result = sha384->Hash;
    	for (int loop = 0; loop < 24; loop++)
    		Key[loop] = result[loop];
    	for (int loop = 24; loop < 40; loop++)
    		IV[loop - 24] = result[loop];
    }
    public:
    	String ^ Crypter(String ^original, String ^keyPhrase)
    {
        array<unsigned char> ^Key = gcnew array<unsigned char>(24);
        array<unsigned char> ^IV = gcnew array<unsigned char>(16);
     
        GenerateKey(keyPhrase, Key, IV);
     
        ASCIIEncoding ^textConverter = gcnew ASCIIEncoding();
        RijndaelManaged ^myRijndael = gcnew RijndaelManaged();
        array<unsigned char> ^encrypted;
        array<unsigned char> ^toEncrypt;
     
        myRijndael->Key = Key;
        myRijndael->IV = IV;
    ICryptoTransform ^encryptor = myRijndael->CreateEncryptor(Key, IV);
        MemoryStream ^msEncrypt = gcnew MemoryStream();
    	CryptoStream ^csEncrypt = gcnew CryptoStream(msEncrypt, encryptor, CryptoStreamMode::Write);
     
        toEncrypt = textConverter->GetBytes(original);
     
        csEncrypt->Write(toEncrypt, 0, toEncrypt->Length);
        csEncrypt->FlushFinalBlock();
     
        encrypted = msEncrypt->ToArray();
    	return Convert::ToBase64String(encrypted);
    }
     
     
    };
    }
    il me mets exception : Could not find file 'h:\Data\Visual Studio 2005\Projects\crypt_file\crypt_file\Saisir un fichier'.
    en fait il prend pas en compte ce que l utilisateur a rentrer, il cherche le fichier 'h:\Data\Visual Studio 2005\Projects\crypt_file\crypt_file\Saisir un fichier'.

+ R�pondre � la discussion
Cette discussion est r�solue.

Discussions similaires

  1. [MSChart] creation de courbe sous visual C++
    Par gabriel knight dans le forum MFC
    R�ponses: 5
    Dernier message: 18/09/2006, 14h32
  2. Impression sous visual c++
    Par zeze511 dans le forum MFC
    R�ponses: 2
    Dernier message: 16/02/2004, 12h02
  3. probl�me de compilation sous visual C++
    Par fabmili dans le forum MFC
    R�ponses: 4
    Dernier message: 08/02/2004, 19h52
  4. R�ponses: 3
    Dernier message: 28/01/2004, 10h46
  5. Deplacer un curseur dans un RichEdit sous visual c
    Par tweek dans le forum Windows
    R�ponses: 7
    Dernier message: 14/01/2004, 00h29

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo