# Class: HashStrategy

## vertx-auth-mongo-js/hash_strategy~ HashStrategy

#### new HashStrategy()

Determines how the hashing is computed in the implementation You can implement this to provide a different hashing strategy to the default.

Source:
  - vertx-auth-mongo-js/hash_strategy.js, line 31

### Methods

#### computeHash(password, user) → {string}

Compute the hashed password given the unhashed password and the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`password` | string | the unhashed password
`user` | User | the user to get the salt for. This paramter is needed, if the is declared to be used

Source:
  - vertx-auth-mongo-js/hash_strategy.js, line 44

##### Returns:

the hashed password

Type
  string

#### getSalt(user) → {string}

Retrieve the salt. The source of the salt can be the external salt or the propriate column of the given user, depending on the defined HashSaltStyle

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | User | the user to get the salt for. This paramter is needed, if the is declared to be used

Source:
  - vertx-auth-mongo-js/hash_strategy.js, line 73

##### Returns:

null in case of the salt of the user or a defined external salt

Type
  string

#### getSaltStyle() → {Object}

Get the defined HashSaltStyle of the current instance

Source:
  - vertx-auth-mongo-js/hash_strategy.js, line 113

##### Returns:

the saltStyle

Type
  Object

#### getStoredPwd(user) → {string}

Retrieve the password from the user, or as clear text or as hashed version, depending on the definition

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | User | the user to get the stored password for

Source:
  - vertx-auth-mongo-js/hash_strategy.js, line 58

##### Returns:

the password, either as hashed version or as cleartext, depending on the preferences

Type
  string

#### setExternalSalt(salt)

Set an external salt. This method should be used in case of

##### Parameters:

Name | Type | Description
--- | --- | ---
`salt` | string | the salt, which shall be used

Source:
  - vertx-auth-mongo-js/hash_strategy.js, line 86

#### setSaltStyle(saltStyle)

Set the saltstyle as defined by HashSaltStyle.

##### Parameters:

Name | Type | Description
--- | --- | ---
`saltStyle` | Object | the HashSaltStyle to be used

Source:
  - vertx-auth-mongo-js/hash_strategy.js, line 99