gregorj/correct-horse 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gregorj/correct-horse

Composer 安装命令:

composer require gregorj/correct-horse

包简介

A random passphrase generator inspired by Randall Munroes XKCD #936

README 文档

README

License: MIT Maintainability Test Coverage Packagist Version

A random passphrase generator inspired by Randall Munroes XKCD #936, bbusschots/hsxkpasswd, and matt-allan/battery-staple. Thanks!

Why??

I needed a generator for handing out initial passwords in PHP. The password should not be easy to guess, especially not for a computer, and the person receiving the password should be able to enter the password fast and without mistakes.

The comic that inspired a lot of people

To anyone who understands information theory and security and is in an infuriating argument with someone who does not (possibly involving mixed case), I sincerely apologize.

Dictionary

This repository contains a German word list based on the GPL-licensed German dictionary for WinEdit by Juergen Vierheilig, copied from Crypt::HSXKPasswd::Dictionary::DE. I tried to rid the word list of NSFW words.

In order to add dictionaries, either implement the \GregorJ\CorrectHorse\DictionaryInterface or just copy files into the dict directory and use \GregorJ\CorrectHorse\Dictionaries\DictionaryFile.

Usage

composer require gregorj/correct-horse
<?php

require_once 'vendor/autoload.php';

use GregorJ\CorrectHorse\Dictionaries\DictionaryFile;
use GregorJ\CorrectHorse\Generators\RandomNumbers;
use GregorJ\CorrectHorse\Generators\RandomWord;
use GregorJ\CorrectHorse\Generators\RandomWords;
use GregorJ\CorrectHorse\Generators\RandomCharacter;
use GregorJ\CorrectHorse\PassphraseGenerator;

$passphrase = new PassphraseGenerator();
// separate the random items of the passphrase with a special character
$passphrase->setSeparator(new RandomCharacter(['-', '#', '.', ' ']));
// random numbers should be between 1 and 99
$randomNumbers = new RandomNumbers();
$randomNumbers->setMinAndMax(1,99);
// add one random number at the beginning
$passphrase->add($randomNumbers, 1);
// add 4 random lower or upper case words
$passphrase->add(
    new RandomWords(
        new RandomWord(new DictionaryFile('dict-de-lc.txt')),
        new RandomWord(new DictionaryFile('dict-de-uc.txt'))
    ),
    4
);
// finally, add another random number
$passphrase->add($randomNumbers, 1);
// now let's generate a random passphrase
echo $passphrase->generate().PHP_EOL;
//9 korrekt Pferd Batterie Heftklammer 36

Testing

There are unit tests for every class.

docker run \
    --init \
    --rm \
    --volume $(pwd):/app \
    --workdir /app \
    php:7.2 vendor/bin/phpunit

统计信息

  • 总下载量: 213
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固