You are here

public function MobileNumberUtil::codeHash in Mobile Number 2.0.x

Same name and namespace in other branches
  1. 8 src/MobileNumberUtil.php \Drupal\mobile_number\MobileNumberUtil::codeHash()

Generate hash given token and code.

Parameters

\libphonenumber\PhoneNumber $mobile_number: Phone number object.

string $token: Token.

string $code: Verification code.

Return value

string Hash string.

Overrides MobileNumberUtilInterface::codeHash

2 calls to MobileNumberUtil::codeHash()
MobileNumberUtil::registerVerificationCode in src/MobileNumberUtil.php
Registers code for mobile number and returns it's token.
MobileNumberUtil::verifyCode in src/MobileNumberUtil.php
Verifies input code matches code sent to user.

File

src/MobileNumberUtil.php, line 342

Class

MobileNumberUtil
Turns a render array into a HTML string.

Namespace

Drupal\mobile_number

Code

public function codeHash(PhoneNumber $mobile_number, $token, $code) {
  $number = $this
    ->getCallableNumber($mobile_number);
  $secret = $this->configFactory
    ->getEditable('mobile_number.settings')
    ->get('verification_secret');
  return sha1("{$number}{$secret}{$token}{$code}");
}