TestController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Components\AsyncResponse;
  4. use App\Components\Database;
  5. use App\Components\ErrorPush;
  6. use App\Exceptions\Exception;
  7. use App\Services\WaybillService;
  8. use App\User;
  9. use App\Waybill;
  10. use Illuminate\Http\Request;
  11. use Illuminate\Support\Facades\DB;
  12. use Illuminate\Support\Facades\Hash;
  13. class TestController extends Controller
  14. {
  15. use AsyncResponse, ErrorPush, Database;
  16. const ASNREFERENCE_2 = 'ASNREFERENCE2';
  17. public function __construct()
  18. {
  19. $this->data["active_test"] = "active";
  20. }
  21. public function method(Request $request, $method)
  22. {
  23. try {
  24. return call_user_func([$this, $method], $request);
  25. }catch (\BadMethodCallException $e){
  26. dd("方法不存在");
  27. }
  28. }
  29. public function test(){
  30. $a = "12345678";
  31. Hash::check($a,$hash);
  32. $hash = password_hash($a, PASSWORD_BCRYPT, ['cost' => 10]);
  33. $prefix = substr($hash, 0 ,29);
  34. //dd(crypt($a, $prefix),$a,$prefix);
  35. dd($hash === crypt($a, $prefix));
  36. $strs="QWERTYUIOPASDFGHJKLZXCVBNM1234567890qwertyuiopasdfghjklzxcvbnm";
  37. $users = User::query()->get();
  38. foreach ($users as $user){
  39. $name=substr(str_shuffle($strs),mt_rand(0,strlen($strs)-11),6);
  40. try {
  41. DB::connection("system")->insert("insert into sys_user(id,username,password,email,salt,service,create_time) VALUES(?,?,?,?,?,?,?)",[
  42. $user->id,$user->name,$user->password,$user->email,$name, "SWMS", date('Y-m-d H:i:s')
  43. ]);
  44. }catch (\Exception $e){
  45. dump($user);
  46. }
  47. }
  48. }
  49. }