Laravel 如何在内部创建验证电子邮件的某些部分?

How does Laravel interally create certain parts of the verification email?

使用 Laravel 创建验证电子邮件时,link 最终可能会这样:

.../verify/1/3f4f10efdbac36ec6892bb3572ac6683ff663ad8?expires=1641580767&signature=babf2d50deb610a551d0477132193abb595d8664b56a9074c38f5b3789933ad

  1. 在“verify/1/”之后似乎有一些长度为 40 的散列。
  2. 最后一个查询参数“signature”的散列长度为 60。

我的问题是:这些散列是如何创建的?使用了哪个散列函数,输入字符串是什么?还有这些部分的用途是什么?

1- verify/1/之后的第一部分是注册用户邮箱的sha1。 我们使用它来确保我们验证我们在数据库中拥有的相同电子邮件以及用户注册的电子邮件。

2- url 的最后一部分是 sha256 signature to make sure the url is not altered by a malicious user. Any modification to the url will make the signature fails. Note that the signature is checked with the Laravel Signed middleware

所以这基本上是防止恶意用户的安全措施。
更多信息:
生成的link会在通知class这里:src/Illuminate/Auth/Notifications/VerifyEmail.php

一旦用户点击了link,就会在下面的文件中进行处理和检查:vendor/laravel/ui/auth-backend/VerifiesEmails.php