C# Class TShockAPI.DB.User

A database user.
Show file Open project: NyxStudios/TShock Class Usage Examples

Protected Properties

Property Type Description
HashTypes Func>.Dictionary

Public Methods

Method Description
CreateBCryptHash ( string password ) : void

Creates a BCrypt hash for a user and stores it in this object.

CreateBCryptHash ( string password, int workFactor ) : void

Creates a BCrypt hash for a user and stores it in this object.

User ( ) : System

Default constructor for a user object; holds no data.

User ( string name, string pass, string uuid, string group, string registered, string last, string known ) : System

Constructor for the user object, assuming you define everything yourself.

VerifyPassword ( string password ) : bool

Verifies if a password matches the one stored in the database. If the password is stored in an unsafe hashing algorithm, it will be converted to BCrypt. If the password is stored using BCrypt, it will be re-saved if the work factor in the config is greater than the existing work factor with the new work factor.

Protected Methods

Method Description
HashPassword ( byte bytes ) : string

Returns a hashed string for a given string based on the config file's hash algo

HashPassword ( string password ) : string

Returns a hashed string for a given string based on the config file's hash algo

UpgradePasswordToBCrypt ( string password ) : void

Upgrades a password to BCrypt, from an insecure hashing algorithm.

UpgradePasswordWorkFactor ( string password ) : void

Upgrades a password to the highest work factor available in the config.

Method Details

CreateBCryptHash() public method

Creates a BCrypt hash for a user and stores it in this object.
public CreateBCryptHash ( string password ) : void
password string The plain text password to hash
return void

CreateBCryptHash() public method

Creates a BCrypt hash for a user and stores it in this object.
public CreateBCryptHash ( string password, int workFactor ) : void
password string The plain text password to hash
workFactor int The work factor to use in generating the password hash
return void

HashPassword() protected method

Returns a hashed string for a given string based on the config file's hash algo
protected HashPassword ( byte bytes ) : string
bytes byte bytes to hash
return string

HashPassword() protected method

Returns a hashed string for a given string based on the config file's hash algo
protected HashPassword ( string password ) : string
password string string to hash
return string

UpgradePasswordToBCrypt() protected method

Upgrades a password to BCrypt, from an insecure hashing algorithm.
protected UpgradePasswordToBCrypt ( string password ) : void
password string The raw user password (unhashed) to upgrade
return void

UpgradePasswordWorkFactor() protected method

Upgrades a password to the highest work factor available in the config.
protected UpgradePasswordWorkFactor ( string password ) : void
password string The raw user password (unhashed) to upgrade
return void

User() public method

Default constructor for a user object; holds no data.
public User ( ) : System
return System

User() public method

Constructor for the user object, assuming you define everything yourself.
public User ( string name, string pass, string uuid, string group, string registered, string last, string known ) : System
name string The user's name.
pass string The user's password hash.
uuid string The user's UUID.
group string The user's group name.
registered string The unix epoch for the registration date.
last string The unix epoch for the last access date.
known string The known IPs for the user, serialized as a JSON object
return System

VerifyPassword() public method

Verifies if a password matches the one stored in the database. If the password is stored in an unsafe hashing algorithm, it will be converted to BCrypt. If the password is stored using BCrypt, it will be re-saved if the work factor in the config is greater than the existing work factor with the new work factor.
public VerifyPassword ( string password ) : bool
password string The password to check against the user object.
return bool

Property Details

HashTypes protected property

A dictionary of hashing algorithms and an implementation object.
protected Dictionary> HashTypes
return Func>.Dictionary