基于模式的密钥生成器

1.2.5 2023-07-19 01:26 UTC

This package is not auto-updated.

Last update: 2024-09-26 05:22:59 UTC


README

此文档也提供葡萄牙语版本 葡萄牙语巴西.

此插件正在开发中,使用时可能会出现意外的行为,请在使用此解决方案时报告您发现的任何错误或问题,以便我们可以使其尽可能适用于您!

Keygen插件是基于用户定义的掩码模式的密钥或序列号生成器。该插件可以生成如下示例中的密钥

6W2F-4RJB-KV0Z-ADA6-4SJ2

它可以用于生成多种用途的密钥,以下是一些示例

  • 重置密码的唯一链接
  • 通过邀请链接进行注册
  • 双因素认证码
  • 文件共享链接
  • 产品兑换密钥
  • 优惠券折扣
  • 推荐码

安装

首先,在您的项目中运行以下命令

composer require kaiopiola/keygen

然后,在您想要加载的PHP文件中调用主类

use Kaiopiola\Keygen\Key;

Keygen的工作原理

如何创建新的密钥

要创建新的密钥,只需在变量中实例化类,然后定义其配置参数,如下例所示

# Instantiating class in a variable:
$exampleKey = new Key;

# Setting parameters:
$exampleKey->setPattern("XXXX-NNNN-LLLL"); // Defines the pattern that the code will use to define its new key. 
// The letters represent the type of content that can be used in that space, as per the rule:
// X - Any letter or number
// N - Numbers only as defined
// L - Letters only as defined
// Any other characters like dashes, dots, slashes, and even other letters and numbers, will not be replaced.
// If this property is not defined, the following will be used by default: XXXXX-XXXXX-XXXXX

$exampleKey->setNumbers("789"); // Defines the numbers that can compose your key, if not defined, it will use by default "0123456789"
$exampleKey->setLetters("ABC"); // Defines the letters that can compose your key, if not defined, it will use by default "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

$exampleKey->generate(); // Generate your key and return a string value with the result

如何创建新的唯一密钥

⚠️ 此特定功能仍在开发中,您在使用时可能会遇到问题或不稳定!
如果您发现任何问题或错误,请 创建新问题 并标记为错误!⚠️

您还可以选择使用以下示例生成唯一的密钥以避免重复

$exampleKey->setExistingKeys([]); // Defines the existing keys that the code will avoid duplicates. Must be type array.

$exampleKey->generateUnique(); // Generate your key and return a string value with the result

这也与 setPatternsetNumberssetLetters 兼容!

注意事项

此项目接受贡献,无论是建议还是对代码的任何改进。请随意参与其开发。

许可协议

MIT许可协议(MIT)。请阅读许可文件以获取更多信息。