Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sha alphabet #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions test/Unit/Password/Implementation/SHA256Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public static function provideTestDetect() {
array('$2$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi', false),
array(SHA256::getPrefix() . '07$usesome illystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi', false),
array(SHA256::getPrefix() . '01$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi', false),

array(SHA256::getPrefix() . "\xE4\"|\xF5|\x08\xC8'\xF054:>\x13\xCB\xED\$6I5JMX./GN9KGHTtvHwvp3mxkNv/Ni7/jomOEBgsiM.", true)
);
}

public static function provideTestCreate() {
return array(
array(1000, 'foo', SHA256::getPrefix() . 'rounds=1000$................$expjG7P4AN4svmCMHxzkAc.s8gNGp0fu4bYVVY8iQo1'),
array(1000, 'bar', SHA256::getPrefix() . 'rounds=1000$................$NYlBKYVTrvSD1CYbsBDngbAm7kyAJk/D9XX.3528r05'),
array(1000, 'baz', SHA256::getPrefix() . 'rounds=1000$................$sN32z5PIeyCOerA52tXRmNvbdcwPd/FqWAmZelaX9z6'),
array(1000, 'foo', SHA256::getPrefix() . "rounds=1000\$\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\$AaIctt3o2mZFLme8WGmPB4yQUd7uV7PT7spV8CJvXA1"),
array(1000, 'bar', SHA256::getPrefix() . "rounds=1000\$\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\$3MGN/aM/1YdTG3AV4IyJq5QEM6zNBDDaLh.rGS/nHI8"),
array(1000, 'baz', SHA256::getPrefix() . "rounds=1000\$\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\$BhLh/zh5GXbIIqmxFpzISUtZbRy9bhefHr9pc.4ri3A"),
);
}

Expand Down Expand Up @@ -149,7 +149,7 @@ public function testVerifyFailException($iterations, $pass, $expect) {

protected function getSHA256MockInstance($iterations) {
$gen = $this->getRandomGenerator(function($size) {
return str_repeat(chr(0), $size);
return str_repeat(chr(1), $size);
});
return new SHA256(array('rounds' => $iterations), $gen);
}
Expand Down
10 changes: 5 additions & 5 deletions test/Unit/Password/Implementation/SHA512Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public static function provideTestDetect() {
array('$2$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi', false),
array(SHA512::getPrefix() . '07$usesome illystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi', false),
array(SHA512::getPrefix() . '01$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi', false),

array(SHA512::getPrefix() . "\xC2?<j\x9A\xE0\xC4\xFCK\x8F\xFD\x87csaO\$Oca/TbK.iCdURjqXCnoIyDNggbVF1FWwjxxUYRuYm6HAPPmQSDxWa3fSgzcPsTyVdjBv4JLBlj4c13YLOpP5f/", true),
);
}

public static function provideTestCreate() {
return array(
array(1000, 'foo', SHA512::getPrefix() . 'rounds=1000$................$DzEAWetj/cXAPD/tGmEgpqyosAIZjLaRQI5DKcZYKSGFbk.mGzvRkDy3skMGqnkS4jRvrFjObXjiv.i5Bnob41'),
array(1000, 'bar', SHA512::getPrefix() . 'rounds=1000$................$lKPnJbXtGAHAid5g7OPcHO3GZjaKv4osoaSPnNAq./mZ4dyGoq9IbAG8d9fcTJ1cxvEALMPki.mbzmNEHjY9b1'),
array(1000, 'baz', SHA512::getPrefix() . 'rounds=1000$................$WZTe6NH6a0MA4vcOjJ9nKZP2hLvr9GhPvYqlOargbJNpzQaluc5sEe.Ep/PF2D79haaMPsFRGsnA2YEW3d7wx1'),
array(1000, 'foo', SHA512::getPrefix() . "rounds=1000\$\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\$5yUq/cJAngIZ0sWBdbZ50jTCUDrMwA08nvnCWUiaCsi6PEuPaUoY8K7MS8IbLj8uE640rjnIF84x1ayZ5UDbq/"),
array(1000, 'bar', SHA512::getPrefix() . "rounds=1000\$\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\$CtKbNszU3gfdh4/aF/V5RNT2a8qljIs9JTINsFConxEvFO3ubFxUqojuOzxCPtqNtdkko/CYO3IGaiAn7ZxE20"),
array(1000, 'baz', SHA512::getPrefix() . "rounds=1000\$\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\$O6m4HWAD6AJo9oSPerzqDlBtGYQytvvtdz98lDwjxOmnlmZodLgtntMYN5l45qfWX54CqDJeS6AGQwXRh2/Ap."),
);
}

Expand Down Expand Up @@ -150,7 +150,7 @@ public function testVerifyFailException($iterations, $pass, $expect) {

protected function getSHA512MockInstance($iterations) {
$gen = $this->getRandomGenerator(function($size) {
return str_repeat(chr(0), $size);
return str_repeat(chr(1), $size);
});
return new SHA512(array('rounds' => $iterations), $gen);
}
Expand Down