Forum de Fandeonepiece2

Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Forum de Fandeonepiece2

Bon dev :)

-20%
Le deal à ne pas rater :
-20% sur le Lot de 2 écrans PC GIGABYTE 27″ LED M27Q
429 € 539 €
Voir le deal

2 participants

    crypter un fichier en MD5

    Aze (admin)
    Aze (admin)
    Admin
    Admin


    Messages : 435
    Date d'inscription : 03/05/2014
    Age : 23
    Localisation : France

    crypter un fichier en MD5 Empty crypter un fichier en MD5

    Message par Aze (admin) Ven 4 Juil - 10:41

    bonjour a tous Smile
    on va apprendre a crypter un fichier en MD5 Smile
    pour cela, il faut copier-coller ce code en dehors d'un sub :
    Code:
     Function GetMD5(ByVal filePath As String)
            Try
                Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider
                Dim f As FileStream = New FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
                md5.ComputeHash(f)
                f.Close()
                f.Dispose()

                Dim hash As Byte() = md5.Hash
                Dim buff As StringBuilder = New StringBuilder
                Dim hashByte As Byte

                For Each hashByte In hash
                    buff.Append(String.Format("{0:X2}", hashByte))
                Next

                Dim md5string As String
                md5string = buff.ToString()

                Return md5string
                md5.Dispose()
                f.Dispose()
            Catch ex As Exception
            End Try
        End Function

    ajouter les imports afin de résoudre les erreurs
    et dans un sub, mettre ce code pour récupérer la valeur :
    Code:
    dim mon_fichier_crypter_en_md5 as string = GetMD5(emp_file)

    cordialement
    Salou
    Salou


    Messages : 145
    Date d'inscription : 02/06/2014
    Age : 29
    Localisation : Le trou du cul de la france

    crypter un fichier en MD5 Empty MEGAvx

    Message par Salou Sam 16 Aoû - 3:45

    Merci,et en c++ sa donne:
    Code:
    //.h file code:

    using namespace System;

    public:
    Object ^GetMD5(String ^filePath);

    //.cpp file code:

    using namespace System;

    Object ^<missing_class_definition>::GetMD5(String ^filePath)
    {
          try
          {
             MD5CryptoServiceProvider ^md5 = gcnew MD5CryptoServiceProvider();
             FileStream ^f = gcnew FileStream(filePath, FileMode->Open, FileAccess::Read, FileShare::Read, 8192);
             md5->ComputeHash(f);
             f->Close();
             delete f;

             array<Byte> ^hash = md5->Hash;
             StringBuilder ^buff = gcnew StringBuilder();
    //         Byte hashByte = 0;

             for each (Byte hashByte in hash)
             {
                buff->Append(String::Format("{0:X2}", hashByte));
             }

             String ^md5string = nullptr;
             md5string = buff->ToString();

             return md5string;
             delete md5;
             delete f;
          }
          catch (Exception ^ex)
          {
          }
          return nullptr;
       }
    Code:

    String ^mon_fichier_crypter_en_md5 = GetMD5(emp_file);
    S'il y a une erreur dit le moi.

    Cordialement.

      La date/heure actuelle est Jeu 28 Mar - 21:33