diff --git a/src/Application/Model/d3totp.php b/src/Application/Model/d3totp.php index 94576a5..c255de3 100644 --- a/src/Application/Model/d3totp.php +++ b/src/Application/Model/d3totp.php @@ -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); } /** diff --git a/src/tests/unit/Application/Model/d3totpTest.php b/src/tests/unit/Application/Model/d3totpTest.php index 2d2be83..ce3dbc3 100644 --- a/src/tests/unit/Application/Model/d3totpTest.php +++ b/src/tests/unit/Application/Model/d3totpTest.php @@ -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); } /**