121 lines
3.1 KiB
C#
121 lines
3.1 KiB
C#
using BS.Shared;
|
|
using System;
|
|
using System.IO;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace BeWo.Data.Entities
|
|
{
|
|
public class PasswortVerlauf : BeWoEntityBase
|
|
{
|
|
|
|
public static string PropertyName_ApplicationUserOid = "ApplicationUserOid";
|
|
|
|
public static string PropertyName_ErstellDatum = "ErstellDatum";
|
|
|
|
public static string PropertyName_Passwort = "Passwort";
|
|
|
|
public static string PropertyName_Salt = "Salt";
|
|
|
|
private readonly byte[] _Rc2IV = { 35, 138, 177, 253, 227, 63, 2, 27 };
|
|
|
|
private readonly byte[] _Rc2Key = { 174, 130, 219, 185, 185, 221, 96, 50, 37, 212, 81, 121, 71, 206, 130, 153 };
|
|
|
|
private string _Passwort;
|
|
|
|
private DateTime _ErstellDatum;
|
|
|
|
private long? _ApplicationUserOid;
|
|
|
|
private string _Salt;
|
|
|
|
|
|
public virtual string Passwort
|
|
{
|
|
get { return _Passwort; }
|
|
|
|
set
|
|
{
|
|
if (AreDifferent(_Passwort, value))
|
|
{
|
|
_Passwort = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual DateTime ErstellDatum
|
|
{
|
|
get
|
|
{
|
|
return this._ErstellDatum;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._ErstellDatum, value))
|
|
{
|
|
this._ErstellDatum = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual long? ApplicationUserOid
|
|
{
|
|
get
|
|
{
|
|
return this._ApplicationUserOid;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._ApplicationUserOid, value))
|
|
{
|
|
this._ApplicationUserOid = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual string Salt
|
|
{
|
|
get { return _Salt; }
|
|
|
|
set
|
|
{
|
|
if (AreDifferent(_Salt, value))
|
|
{
|
|
_Salt = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public virtual string RC2EncryptedHash
|
|
{
|
|
get
|
|
{
|
|
string lResult = string.Empty;
|
|
var lRc2CSP = new RC2CryptoServiceProvider();
|
|
ICryptoTransform lEncryptor = lRc2CSP.CreateEncryptor(_Rc2Key, _Rc2IV);
|
|
|
|
using (var msEncrypt = new MemoryStream())
|
|
{
|
|
using (var csEncrypt = new CryptoStream(msEncrypt, lEncryptor, CryptoStreamMode.Write))
|
|
{
|
|
byte[] toEncrypt = Encoding.UTF8.GetBytes(Passwort);
|
|
|
|
csEncrypt.Write(toEncrypt, 0, toEncrypt.Length);
|
|
csEncrypt.FlushFinalBlock();
|
|
|
|
byte[] encrypted = msEncrypt.ToArray();
|
|
lResult = BitConverter.ToString(encrypted);
|
|
}
|
|
}
|
|
if (!String.IsNullOrEmpty(lResult))
|
|
lResult = lResult.Replace("-", "").ToLower();
|
|
|
|
return lResult;
|
|
}
|
|
}
|
|
|
|
}
|
|
} |