fix seed encrypting

This commit is contained in:
Daniel Seifert 2019-08-13 23:09:51 +02:00
bovenliggende 51ff19bf42
commit f4bf78cb1e
2 gewijzigde bestanden met toevoegingen van 4 en 1 verwijderingen

Bestand weergeven

@ -251,7 +251,7 @@ class d3totp extends BaseModel
$iv = openssl_random_pseudo_bytes($ivlen);
$ciphertext_raw = openssl_encrypt($plaintext, $cipher, $key, $options=OPENSSL_RAW_DATA, $iv);
$hmac = hash_hmac('sha256', $ciphertext_raw, $key, $as_binary=true);
return $this->d3Base64_decode($iv.$hmac.$ciphertext_raw);
return base64_encode($iv.$hmac.$ciphertext_raw);
}
/**

Bestand weergeven

@ -732,8 +732,11 @@ class d3totpTest extends d3TotpUnitTestCase
{
$sReturn = $this->callMethod($this->_oModel, 'encrypt', ['foobar']);
// indirect tests, because string changes on every call
$this->assertInternalType('string', $sReturn);
$this->assertNotSame('foobar', $sReturn);
$this->assertStringEndsWith('==', $sReturn);
$this->assertTrue(strlen($sReturn) === 88);
}
/**