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

ASP Discussion :

stockage de mot de passe. ASP contre md5


Sujet :

ASP

  1. #1
    Membre du Club
    Inscrit en
    Octobre 2005
    Messages
    82
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 82
    Points : 56
    Points
    56
    Par défaut stockage de mot de passe. ASP contre md5
    Bonjour !

    quand je programme en php, j'utilise md5 pour crypter mes mot de passe afin de les stocker dans la bdd.

    En asp, pas d'equivalence.

    Pour quelle solutoin avez vous opté?

    Merci

  2. #2
    Expert éminent
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Points : 9 506
    Points
    9 506
    Par défaut
    J'ai trouvé cela sur le net SHA1:
    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
    222
    223
    224
    <%
    function tohex(value)
      value = clng(value)
      tohex = lcase(hex(value))
      do while len(tohex) < 8
        tohex = "0" & tohex
      loop
    end function
     
    function tobin(value)
      dim hexstr
      hexstr = tohex(value)
      tobin = ""
      for i = 1 to len(hexstr)
        select case mid(hexstr, i, 1)
          case "f", "F"
            tobin = tobin & "1111"
          case "e", "E"
            tobin = tobin & "1110"
          case "d", "D"
            tobin = tobin & "1101"
          case "c", "C"
            tobin = tobin & "1100"
          case "b", "B"
            tobin = tobin & "1011"
          case "a", "A"
            tobin = tobin & "1010"
          case "9"
            tobin = tobin & "1001"
          case "8"
            tobin = tobin & "1000"
          case "7"
            tobin = tobin & "0111"
          case "6"
            tobin = tobin & "0110"
          case "5"
            tobin = tobin & "0101"
          case "4"
            tobin = tobin & "0100"
          case "3"
            tobin = tobin & "0011"
          case "2"
            tobin = tobin & "0010"
          case "1"
            tobin = tobin & "0001"
          case else
            tobin = tobin & "0000"
        end select
      next
    end function
     
    function bin2dec(binstr)
      dim flip
      flip = false
      bin2dec = clng(0)
      if left(binstr,1) = "0" then
        for i = 1 to len(binstr)
          if mid(binstr,33-i,1)="1" then
            bin2dec = bin2dec + (2^(i-1))
          end if
        next
      else
        for i = 1 to len(binstr)
          if flip then
            if mid(binstr,33-i,1)="0" then
              bin2dec = bin2dec - (2^(i-1))
            end if
          else
            if mid(binstr,33-i,1)="1" then
              bin2dec = bin2dec - (2^(i-1))
              flip = true
            end if
          end if
        next
      end if
    end function  
     
    function rshift(value,count)
      dim binstr
      if count >= 32 then
        binstr = ""
      elseif count > 0 then
        binstr = left(tobin(value), 32-count)
      else
        binstr = tobin(value)
      end if
      do while len(binstr) < 32
        binstr = "0" + binstr
      loop
      rshift = bin2dec(binstr)  
    end function
     
    function lshift(value,count)
      dim binstr
      if count >= 32 then
        binstr = ""
      elseif count > 0 then
        binstr = right(tobin(value), 32-count)
      else
        binstr = tobin(value)
      end if
      do while len(binstr) < 32
        binstr = binstr + "0"
      loop
      lshift = bin2dec(binstr)
    end function
     
    function rol(value,count)
      rol = lshift(value,count) or rshift(value,32-count)
    end function
     
    function add32(a, b)
      dim bina, binb, total, result, carry
      bina = tobin(a)
      binb = tobin(b)
      result = ""
      carry = "0"
      for i = 1 to 32
        total = 0
        if mid(bina,33-i,1)="1" then total = total + 1
        if mid(binb,33-i,1)="1" then total = total + 1
        if carry="1" then total = total + 1
        select case total
          case 3
            carry = "1"
            result = "1" + result
          case 2
            carry = "1"
            result = "0" + result
          case 1
            carry = "0"
            result = "1" + result
          case else
            carry = "0"
            result = "0" + result
        end select
      next
      add32 = bin2dec(result)    
    end function
     
    function f(b,c,d,t)
      if t < 20 then
        f = (b and c) or ((not b) and d)
      elseif t < 40 then
        f = b xor c xor d
      elseif t < 60 then
        f = (b and c) or (b and d) or (c and d)
      else
        f = b xor c xor d
      end if
    end function
     
    function k(t)
      if t < 20 then
        k = clng(1518500249)
      elseif t < 40 then
        k = clng(1859775393)
      elseif t < 60 then
        k = clng(-1894007588)
      else
        k = clng(-899497514)
      end if
    end function
     
    function pad(message)
      dim l, n
      l = len(message)
      n = (((l+8) \ 64) + 1)*16
      redim m(n-1)
      for i = 0 to n-1
        m(i) = clng(0)
      next
      for i = 0 to l-1
        m(i\4) = m(i\4) or lshift(asc(mid(message,i+1,1)),(24-(i mod 4)*8))
      next
      m(l\4) = m(l\4) or lshift(clng(128),(24-(l mod 4)*8))
      m(n-1) = l*8
      pad = m
    end function
     
    function sha1(message)
      dim h0, h1, h2, h3, h4
      dim a, b, c, d, e, temp
      dim l, n
      dim w(79)
     
      l = len(message)
      n = (((l+8) \ 64) + 1)*16
      m = pad(message)
     
      h0 = clng(1732584193)
      h1 = clng(-271733879)
      h2 = clng(-1732584194)
      h3 = clng(271733878)
      h4 = clng(-1009589776)
     
      for block = 0 to n-1 step 16
        a = h0
        b = h1
        c = h2
        d = h3
        e = h4
        for t = 0 to 79
          if t < 16 then
            w(t) = m(block + t)
          else
            w(t) = rol(w(t-3) xor w(t-8) xor w(t-14) xor w(t-16),1)
          end if
          temp = add32(rol(a,5),add32(f(b,c,d,t),add32(e,add32(w(t),k(t)))))
          e = d
          d = c
          c = rol(b,30)
          b = a
          a = temp
        next
        h0 = add32(h0, a)
        h1 = add32(h1, b)
        h2 = add32(h2, c)
        h3 = add32(h3, d)
        h4 = add32(h4, e)
      next
      sha1 = tohex(h0)+tohex(h1)+tohex(h2)+tohex(h3)+tohex(h4)
    end function
    %>
    "Winter is coming" (ma nouvelle page d'accueil)

  3. #3
    Membre du Club
    Inscrit en
    Octobre 2005
    Messages
    82
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 82
    Points : 56
    Points
    56
    Par défaut
    tu l'utilises?

  4. #4
    Expert éminent
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Points : 9 506
    Points
    9 506
    Par défaut
    Non, je ne l'ai jamais testé. Je le gardais sous le coude.

    "Winter is coming" (ma nouvelle page d'accueil)

  5. #5
    Membre habitué
    Inscrit en
    Octobre 2005
    Messages
    400
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 400
    Points : 128
    Points
    128
    Par défaut
    ce long bou de code il est fait pour crypter les mots de passe en asp?.
    j aimerais crypter les mots de passe alors je peux prendre le code tel quel?
    Si oui, ou faudrait il que je le mette?

    Merci

  6. #6
    Expert éminent
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Points : 9 506
    Points
    9 506
    Par défaut
    Ben, c'est une fonction. Tu la mets où tu veux...
    "Winter is coming" (ma nouvelle page d'accueil)

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    21
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 21
    Points : 24
    Points
    24
    Par défaut
    Salut :

    Un exemple d'algo MD5 et explication concernant sa mise en oeuvre :

    http://rossm.net/Electronics/Computers/Software/ASP/#MD5

    @+

  8. #8
    Membre habitué
    Inscrit en
    Octobre 2005
    Messages
    400
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 400
    Points : 128
    Points
    128
    Par défaut
    hello,
    j ai bien regarder ce site et d autre encore mais .. je ne comprends pas le tres bien le fonctionnement..

    si je veux crypter mon mot de passe quand je m inscrit je dois mettre dans ma page d inscription et de vérification l'include?

    et ensuite, je dois mettre ou
    ca c est pour le faire afficher pour voir si ca crypte avant de l enregistrer

    et au démarrage, une fois qu il est inscrit, on doit mettre aussi md5(pwd) pour qu il le décrypte ?

  9. #9
    Expert éminent
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Points : 9 506
    Points
    9 506
    Par défaut
    MD5 est impossible à décripter (normalement).
    Tu stocks le mot de passe cripté dans ta base. Par la suite, à l'identification tu compares les deux valeurs cryptées, celle saisie par l'internaute et celle de ta base.
    "Winter is coming" (ma nouvelle page d'accueil)

  10. #10
    Inactif
    Inscrit en
    Octobre 2005
    Messages
    150
    Détails du profil
    Informations personnelles :
    Âge : 41

    Informations forums :
    Inscription : Octobre 2005
    Messages : 150
    Points : 101
    Points
    101
    Par défaut
    Citation Envoyé par Immobilis
    MD5 est impossible à décripter (normalement).
    Tu stocks le mot de passe cripté dans ta base. Par la suite, à l'identification tu compares les deux valeurs cryptées, celle saisie par l'internaute et celle de ta base.
    C'est quoi alors l'intérêt de passer par md5 plutôt que de comparer directement un passwd saisi par l'utilisateur à celui de la base de données?

    (\ _ /)
    (='.'=) Voici Lapinou. Aidez le à conquérir le monde
    (")-(") en le reproduisant.

  11. #11
    Expert éminent
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Points : 9 506
    Points
    9 506
    Par défaut
    Ben ca evite qu'un pékin matte les mots de passe en clair dans la BD.

    Ca existe aussi le piratage... Ce serait malin de dire : "Oups, on s'est fait piraté. Il faut qu'on demande à nos XXXX utilisateurs de changer leur mot de passe parce qu'ils étaient en clair dans la base."
    Récupérer le mot de passe crypté ne sert à rien car avant de comparer ton script va réencrypter le mot de passe dejà crypté.

    "Winter is coming" (ma nouvelle page d'accueil)

  12. #12
    Membre habitué
    Inscrit en
    Octobre 2005
    Messages
    400
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 400
    Points : 128
    Points
    128
    Par défaut
    MD5 est propre a php..
    avec asp il faut employer les fonctions Encrypte et Decrypte.

    QQn sait comment ca fontionne? Ou il faut placer le fichier de cryptage et comment faire pour que quand il enregistre il enregistre crypter?

  13. #13
    Expert éminent
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Points : 9 506
    Points
    9 506
    Par défaut
    T'es certaine de ne pas parler d'une techno .NET là?
    MD5, SHA1 existent "nativement" (c-a-d dans le Framework) en .NET.

    Je ne crois pas que MD5 soit un concept PHP mm si c'est eux qui l'on mis à dispo en premier dans le script serveur.

    A+
    "Winter is coming" (ma nouvelle page d'accueil)

  14. #14
    Membre habitué
    Inscrit en
    Octobre 2005
    Messages
    400
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 400
    Points : 128
    Points
    128
    Par défaut
    j avais cru entendre dire que md5 ne s employait qu avec php.. mais j ai du mal comprendre.. je ne suis pas une experte..

    par contre j ai tjs par réussi a crypter mon mot de passe...
    j ai une fonction pour crypter et decrypter mais elle ne doit pas etre juste vu les commentaires des autres forum..

    si qqn a une idée.. sinon je m amuserais ces vacances

  15. #15
    Expert éminent
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Points : 9 506
    Points
    9 506
    "Winter is coming" (ma nouvelle page d'accueil)

  16. #16
    Membre régulier
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    73
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 73
    Points : 84
    Points
    84
    Par défaut
    salut,
    pour crypter sinon ya un composant qui s'appelle AspEncrypt. Seul souis et pas des moindres, il n'est pas gratuit.....mais fonctionne tres bien.

    ++

Discussions similaires

  1. Mot de passe haché avec MD5 dans la base de données
    Par lelapinrusse dans le forum PHP & Base de données
    Réponses: 9
    Dernier message: 13/06/2009, 21h31
  2. crypter mot de passe asp.net et c#
    Par fido1 dans le forum ASP.NET
    Réponses: 1
    Dernier message: 14/09/2008, 15h38
  3. Réponses: 1
    Dernier message: 06/05/2008, 14h29
  4. [Sécurité] Stockage des mots de passe
    Par Jesmar dans le forum Langage
    Réponses: 4
    Dernier message: 29/03/2007, 21h05
  5. [10gR2] Stockage de mots de passe
    Par hotkebab99 dans le forum Oracle
    Réponses: 7
    Dernier message: 10/02/2006, 15h01

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