Skip to content

Commit

Permalink
Created wc_api_hash()
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiosanches committed Jun 8, 2015
1 parent 3697ad9 commit 3f45c87
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions includes/admin/class-wc-admin-api-keys.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ private function update_key() {
'user_id' => $user_id,
'description' => $description,
'permissions' => $permissions,
'consumer_key' => $consumer_key,
'consumer_secret' => $consumer_secret
'consumer_key' => wc_api_hash( $consumer_key ),
'consumer_secret' => wc_api_hash( $consumer_secret )
),
array(
'%d',
Expand Down
4 changes: 2 additions & 2 deletions includes/class-wc-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ protected function create_keys( $app_name, $app_user_id, $scope ) {
'user_id' => $user->ID,
'description' => $description,
'permissions' => $permissions,
'consumer_key' => $consumer_key,
'consumer_secret' => $consumer_secret
'consumer_key' => wc_api_hash( $consumer_key ),
'consumer_secret' => wc_api_hash( $consumer_secret )
),
array(
'%d',
Expand Down
11 changes: 11 additions & 0 deletions includes/wc-core-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -817,3 +817,14 @@ function wc_rand_hash() {
return sha1( wp_rand() );
}
}

/**
* WC API - Hash
*
* @since 2.4.0
* @param string $data
* @return string
*/
function wc_api_hash( $data ) {
return hash_hmac( 'sha256', $data, 'wc-api' );
}

0 comments on commit 3f45c87

Please sign in to comment.