SECUREVAULT : APPLICATION POUR CRYPTER VOS FICHIERS AVEC AES ET RSA
cs_saylar
Messages postés102Date d'inscriptionvendredi 21 avril 2006StatutMembreDernière intervention10 février 2008
-
3 avril 2007 à 18:33
youssefkhlil
Messages postés1Date d'inscriptionjeudi 26 avril 2007StatutMembreDernière intervention12 août 2007
-
12 août 2007 à 13:07
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.
youssefkhlil
Messages postés1Date d'inscriptionjeudi 26 avril 2007StatutMembreDernière intervention12 août 2007 12 août 2007 à 13:07
bon travail avec une bonne interface graphique
ryoussef19
Messages postés34Date d'inscriptionlundi 19 mars 2007StatutMembreDernière intervention25 août 20071 10 mai 2007 à 08:32
En fait je travaille sous visual studio 2005 ( visual c++)
j'ai réussi à trouver des méthodes pour crypter et décrypter mais le problème est que ca ne crypte que des fichiers txt .
ca peut crypter d'autres types de fichiers par exemole un test.zip, mais si je le crypte et je le decrypte j'aurais par exemple un fichier test1.zip
ce fichier quand je veux l'ouvrir il me dit fichier corrompu!
je me suis dit que peut être t'aura une idée!
est ce que quelqu'un a une idée pour pouvoir crypter et decrypter tout genre de fichier
voici le code:
12 août 2007 à 13:07
10 mai 2007 à 08:32
j'ai réussi à trouver des méthodes pour crypter et décrypter mais le problème est que ca ne crypte que des fichiers txt .
ca peut crypter d'autres types de fichiers par exemole un test.zip, mais si je le crypte et je le decrypte j'aurais par exemple un fichier test1.zip
ce fichier quand je veux l'ouvrir il me dit fichier corrompu!
je me suis dit que peut être t'aura une idée!
est ce que quelqu'un a une idée pour pouvoir crypter et decrypter tout genre de fichier
voici le code:
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);
}
public :
String ^ Decrypter(String ^ encryptedString, String ^keyPhrase)
{
array < unsigned char > ^Key = gcnew array < unsigned char >(24);
array < unsigned char > ^IV = gcnew array < unsigned char >(16);
GenerateKey(keyPhrase, Key, IV);
array < unsigned char > ^encrypted = Convert::FromBase64String(encryptedString);
array < unsigned char > ^fromEncrypt;
RijndaelManaged ^myRijndael =
gcnew RijndaelManaged();
ASCIIEncoding ^textConverter =
gcnew ASCIIEncoding();
myRijndael->Key = Key;
myRijndael->IV = IV;
ICryptoTransform ^decryptor = myRijndael->CreateDecryptor(Key, IV);
MemoryStream ^msDecrypt = gcnew MemoryStream(encrypted);
CryptoStream ^csDecrypt = gcnew CryptoStream(msDecrypt, decryptor, CryptoStreamMode::Read);
fromEncrypt = gcnewarray < unsignedchar >(encrypted->Length);
csDecrypt->Read(fromEncrypt, 0, fromEncrypt->Length);
return textConverter->GetString(fromEncrypt);
}
int main( array <System::String ^> ^args){
StreamReader ^sr = gcnew StreamReader( this ->val3);
StreamWriter ^sw = gcnew StreamWriter( this ->val5);
try
{
String ^a = Crypter(sr->ReadToEnd(), this ->GetValue1());
sw->Write(a);
}
catch (Exception^)
{
}
finally
{
sr->Close();
sw->Close();
}
StreamReader ^sr = gcnew StreamReader( this ->val3);
StreamWriter ^sw = gcnew StreamWriter( this ->val5);
try
{
String ^a = Decrypter(sr->ReadToEnd(), this ->GetValue1());
sw->Write(a);
}
catch (Exception^)
{
}
finally
{
sr->Close();
sw->Close();
}
return0;
}
3 avril 2007 à 18:34
3 avril 2007 à 18:33