Skip to content

遇到生成兑换码的需求,因此写一个简单的类库给同事用

License

Notifications You must be signed in to change notification settings

kefengzhang/redemption-code

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redemption Code Generate & Verify

use

composer require soonio/redemption-code

define chars

const CHARS = [
    'H', 'I', 'J', 'K', 'L', '8', '9',
    '3', '4', '5', 'O', 'P', 'Q', 'G',
    'V', 'W', '1', '2', 'X', 'Y', 'Z',
    'A', 'B', 'C', 'D', 'S', 'T', 'U',
    '6', '7', 'M', 'N', 'R', 'E', 'F',
];

generate

$rc = new soonio\rc\RedemptionCode(CHARS, 20);

echo "redemption code: {$rc->generate()}\n";

verify

$bool = (new soonio\rc\RedemptionCode(CHARS, 20))->verify('I7AXXDN2TZXPQT788GV3');
echo $bool ? "验证通过\n" : "验证拒绝";

Differentiation

Only need to disrupt the order of the array of characters "CHARS" can be different in other people's projects.

Develop

run demo

 php examples/index.php

test

composer test

About

遇到生成兑换码的需求,因此写一个简单的类库给同事用

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%