#include <stdio.h>
#include <string.h>
#include <math.h>




unsigned long  fonction_hachage_modulo(char mot[100], int taille);

unsigned long  fonction_hachage_modulo(char mot[100], int taille)


    {
        unsigned long somme=0;
        char caractere;
        int ascii;
        int nb_base=128;






        for (int i =0 ;i<strlen(mot);i++)


            {
                caractere= mot[i];
                ascii= (int)caractere;
                somme+= (pow(nb_base,i)*ascii)%taille;


            }
            
            return somme;

    }


int main() 
{
    char mot[100] = "ISMIN";
    unsigned long resultat = fonction_hachage(mot);
    printf("Le hachage de '%s' est : %lu\n", mot, resultat);

    // Tester avec un autre mot
    strcpy(mot, "test");
    resultat = fonction_hachage(mot);
    printf("Le hachage de '%s' est : %lu\n", mot, resultat);

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: