PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/zend/good/ext/standard/tests/strings/crypt.php

http://github.com/facebook/hiphop-php
PHP | 21 lines | 19 code | 2 blank | 0 comment | 0 complexity | 49698abecd76a11a81719d0d68af7772 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?hh
  2. <<__EntryPoint>> function main(): void {
  3. $str = 'rasmuslerdorf';
  4. $salt1 = 'rl';
  5. $res_1 = 'rl.3StKT.4T8M';
  6. $salt2 = '_J9..rasm';
  7. $res_2 = '_J9..rasmBYk8r9AiWNc';
  8. $salt3 = '$1$rasmusle$';
  9. $res_3 = '$1$rasmusle$rISCgZzpwk3UhDidwXvin0';
  10. $salt4 = '$2a$07$rasmuslerd............';
  11. $res_4 = '$2a$07$rasmuslerd............nIdrcHdxcUxWomQX9j6kvERCFjTg7Ra';
  12. echo (CRYPT_STD_DES) ? ((crypt($str, $salt1) === $res_1) ? 'STD' : 'STD - ERROR') : 'STD', "\n";
  13. echo (CRYPT_EXT_DES) ? ((crypt($str, $salt2) === $res_2) ? 'EXT' : 'EXT - ERROR') : 'EXT', "\n";
  14. echo (CRYPT_MD5) ? ((crypt($str, $salt3) === $res_3) ? 'MD5' : 'MD5 - ERROR') : 'MD5', "\n";
  15. echo (CRYPT_BLOWFISH) ? ((crypt($str, $salt4) === $res_4) ? 'BLO' : 'BLO - ERROR') : 'BLO', "\n";
  16. var_dump(crypt($str));
  17. try { var_dump(crypt()); } catch (Exception $e) { echo "\n".'Warning: '.$e->getMessage().' in '.__FILE__.' on line '.__LINE__."\n"; }
  18. try { var_dump(crypt("", "", "")); } catch (Exception $e) { echo "\n".'Warning: '.$e->getMessage().' in '.__FILE__.' on line '.__LINE__."\n"; }
  19. }