Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/04/09 19:42:18 (15 years ago)
Author:
svonolfe
Message:

Passwords are now stored in MD5 in the database (#532)

Location:
trunk/sources/HeuristicLab.Security.Contracts/3.2
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Security.Contracts/3.2/BusinessObjects/User.cs

    r1656 r1737  
    2424using System.Text;
    2525using System.Runtime.Serialization;
     26using System.Security.Cryptography;
    2627
    2728namespace HeuristicLab.Security.Contracts.BusinessObjects {
     
    2930  [DataContract]
    3031  public class User : PermissionOwner {
     32    private static string getMd5Hash(string input) {
     33      // Create a new instance of the MD5CryptoServiceProvider object.
     34      MD5 md5Hasher = MD5.Create();
     35
     36      // Convert the input string to a byte array and compute the hash.
     37      byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));
     38
     39      // Create a new Stringbuilder to collect the bytes
     40      // and create a string.
     41      StringBuilder sBuilder = new StringBuilder();
     42
     43      // Loop through each byte of the hashed data
     44      // and format each one as a hexadecimal string.
     45      for (int i = 0; i < data.Length; i++) {
     46        sBuilder.Append(data[i].ToString("x2"));
     47      }
     48
     49      // Return the hexadecimal string.
     50      return sBuilder.ToString();
     51    }
     52
     53
    3154    [DataMember]
    3255    public String Login { get; set; }
     56
     57    private String password;
     58   
    3359    [DataMember]
    34     public String Password { get; set; }
     60    public String Password {
     61      get {
     62        return this.password;
     63      }
     64      set {
     65        this.password = getMd5Hash(value);
     66      }
     67    }
     68
     69    public void SetPlainPassword(String password) {
     70      this.password = password;
     71    }
     72
    3573    [DataMember]
    3674    public String MailAddress { get; set; }
  • trunk/sources/HeuristicLab.Security.Contracts/3.2/Interfaces/IPermissionManager.cs

    r1735 r1737  
    1919    void EndSession(Guid sessionId);
    2020
    21     [OperationContract]
    22     [FaultContractAttribute(typeof(CommunicationException))]
    23     void TestServer();
    2421  }
    2522}
Note: See TracChangeset for help on using the changeset viewer.