rancoud / crypt
加密包
3.2.9
2024-09-02 11:39 UTC
Requires
- php: >=7.4.0
- ext-mbstring: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16 || ^3.0
- phpunit/phpunit: ^9.1 || ^10.0 || ^11.0
- squizlabs/php_codesniffer: ^3.5
README
Crypt默认使用Argon2id,备用方案为Argon2i和bcrypt。
安装
composer require rancoud/crypt
如何使用?
$password = 'my_password'; $hash = Crypt::hash($password); $result = Crypt::verify($password, $hash); // use only Argon2i Crypt::useArgon2i(); // use only bcrypt Crypt::useBcrypt();
Crypt
静态方法
主要功能
- hash(password: string): string
- needsRehash(hash: string): bool
- verify(password: string, hash: string): bool
算法
- getCurrentAlgo(): int
- useArgon2id(): void
- useArgon2i(): void
- useBcrypt(): void
选项
- setOptionArgon2iMemoryCost(bytes: int): void
- setOptionArgon2iThreads(threads: int): void
- setOptionArgon2iTimeCost(time: int): void
- setOptionBcryptCost(rounds: int): void
- getOptionsArgon2i(): array
- getOptionsBcrypt(): array
随机字符串
- getRandomString([length: int = 64], [characters: ?string = null]): string
- getCharactersForRandomString(): string
- setCharactersForRandomString(characters: string): void
如何开发
composer ci
用于php-cs-fixer、phpunit和覆盖率
composer lint
用于php-cs-fixer
composer test
用于phpunit和覆盖率