{"id":229,"date":"2010-01-29T06:54:13","date_gmt":"2010-01-28T21:54:13","guid":{"rendered":"http:\/\/yamazon.org\/?p=229"},"modified":"2010-01-29T06:54:13","modified_gmt":"2010-01-28T21:54:13","slug":"php%e3%81%a7%e3%83%a9%e3%83%b3%e3%83%80%e3%83%a0%e3%81%aa%e3%83%91%e3%82%b9%e3%83%af%e3%83%bc%e3%83%89%e3%82%92%e7%94%9f%e6%88%90","status":"publish","type":"post","link":"https:\/\/apr20.net\/?p=229","title":{"rendered":"php\u3067\u30e9\u30f3\u30c0\u30e0\u306a\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u751f\u6210"},"content":{"rendered":"<p>\u4f7f\u7528\u4f8b<\/p>\n<p>\/\/\u30d1\u30b9\u30ef\u30fc\u30c9\u751f\u6210\u30af\u30e9\u30b9\u8aad\u307f\u8fbc\u307f<br \/>\nrequire_once &#8216;My\/Password.php&#8217;;<\/p>\n<p>\/\/\u30c7\u30d5\u30a9\u30eb\u30c8\u306f8\u6841\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u751f\u6210\u3055\u308c\u307e\u3059<br \/>\n$password = My_Password::getPassword();<br \/>\nvar_dump($password);<\/p>\n<p>\/\/\u300e32\u6841\u3001\u5c0f\u6587\u5b57\u82f1\u5b57\u306e\u307f\u300f\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u751f\u6210<br \/>\n$password = My_Password::getPassword(32, &#8216;small&#8217;);<br \/>\nvar_dump($password);<br \/>\n<!--more--><br \/>\n\u51fa\u529b\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>string(8) &#8220;txRC4hLX&#8221;<br \/>\nstring(32) &#8220;zcyhuypsvbjgrfiacxrfhwusuiuulllb&#8221;<\/p>\n<p>\u8aac\u660e<br \/>\nint $lenght<\/p>\n<p>\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u6841\u6570 (\u30c7\u30d5\u30a9\u30eb\u30c8 8\u6841 )<br \/>\nstring $mode<\/p>\n<p>\u6587\u5b57\u5217\u306e\u7a2e\u985e\u3092\u6307\u5b9a (\u30c7\u30d5\u30a9\u30eb\u30c8 \u5927\u5c0f\u6587\u5b57\u82f1\u6570\u5b57 )<br \/>\nsmall \u2013 \u5c0f\u6587\u5b57\u82f1\u5b57<br \/>\nlarge \u2013 \u5927\u6587\u5b57\u82f1\u5b57<br \/>\nsmallalnum \u2013 \u5c0f\u6587\u5b57\u82f1\u6570\u5b57<br \/>\nlargealnum \u2013 \u5927\u6587\u5b57\u82f1\u6570\u5b57<br \/>\nnum \u2013 \u6570\u5b57<br \/>\nalphabet \u5927\u5c0f\u6587\u5b57\u82f1\u5b57<br \/>\nalnum \u2013 \u5927\u5c0f\u6587\u5b57\u82f1\u6570\u5b57<br \/>\n\u30d1\u30b9\u30ef\u30fc\u30c9\u751f\u6210\u30af\u30e9\u30b9My_Password\u30bd\u30fc\u30b9<\/p>\n<p>class My_password<br \/>\n{<\/p>\n<p>    \/**<br \/>\n     * \u30d5\u30a1\u30a4\u30eb\u540d\u30fb\u30e6\u30cb\u30fc\u30afID\u30fb\u30d1\u30b9\u30ef\u30fc\u30c9\u751f\u6210<br \/>\n     *<br \/>\n     * @param  integer $length  \u6587\u5b57\u5217\u9577 default:8 (1-256)<br \/>\n     * @param  string  $mode    \u30e2\u30fc\u30c9   default:&#8217;alnum&#8217;<br \/>\n     * @return array<br \/>\n     *\/<br \/>\n    public static function getPassword($length = 8, $mode = &#8216;alnum&#8217;)<br \/>\n    {<br \/>\n         if ($length < 1 || $length > 256) {<br \/>\n             return false;<br \/>\n         }<br \/>\n         $smallAlphabet = &#8216;abcdefghijklmnopqrstuvwxyz&#8217;;<br \/>\n         $largeAlphabet = &#8216;ABCDEFGHIJKLMNOPQRSTUVWXYZ&#8217;;<br \/>\n         $numeric       = &#8216;0123456789&#8217;;<\/p>\n<p>         switch ($mode) {<\/p>\n<p>         \/\/ \u5c0f\u6587\u5b57\u82f1\u5b57<br \/>\n         case &#8216;small&#8217;:<br \/>\n             $chars = $smallAlphabet;<br \/>\n             break;<\/p>\n<p>         \/\/ \u5927\u6587\u5b57\u82f1\u5b57<br \/>\n         case &#8216;large&#8217;:<br \/>\n             $chars = $largeAlphabet;<br \/>\n             break;<\/p>\n<p>         \/\/ \u5c0f\u6587\u5b57\u82f1\u6570\u5b57<br \/>\n         case &#8216;smallalnum&#8217;:<br \/>\n             $chars = $smallAlphabet . $numeric;<br \/>\n             break;<\/p>\n<p>         \/\/ \u5927\u6587\u5b57\u82f1\u6570\u5b57<br \/>\n         case &#8216;largealnum&#8217;:<br \/>\n             $chars = $largeAlphabet . $numeric;<br \/>\n             break;<\/p>\n<p>         \/\/ \u6570\u5b57<br \/>\n         case &#8216;num&#8217;:<br \/>\n             $chars = $numeric;<br \/>\n             break;<\/p>\n<p>         \/\/ \u5927\u5c0f\u6587\u5b57\u82f1\u5b57<br \/>\n         case &#8216;alphabet&#8217;:<br \/>\n             $chars = $smallAlphabet . $largeAlphabet;<br \/>\n             break;<\/p>\n<p>         \/\/ \u5927\u5c0f\u6587\u5b57\u82f1\u6570\u5b57<br \/>\n         case &#8216;alnum&#8217;:<br \/>\n         default:<br \/>\n             $chars = $smallAlphabet . $largeAlphabet . $numeric;<br \/>\n             break;<br \/>\n         }<\/p>\n<p>         $charsLength = strlen($chars);<\/p>\n<p>         $password = &#8221;;<br \/>\n         for ($i = 0; $i < $length; $i++) {\n             $num = mt_rand(0, $charsLength - 1);\n             $password .= $chars{$num};\n         }\n\n         return $password;\n    }\n\n}\n\n\u307e\u305f\u3001PEAR\u306b\u3082\u985e\u4f3c\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3053\u3061\u3089\u3082\u3054\u53c2\u8003\u4e0b\u3055\u3044\u3002\nhttp:\/\/pear.php.net\/package\/Text_Password\n\n\n\u53c2\u7167\u5143\uff1ahttp:\/\/www.plusmb.jp\/2009\/02\/06\/2439.html\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528\u4f8b \/\/\u30d1\u30b9\u30ef\u30fc\u30c9\u751f\u6210\u30af\u30e9\u30b9\u8aad\u307f\u8fbc\u307f require_once &#038;#8216&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[126,234,252],"class_list":["post-229","post","type-post","status-publish","format-standard","hentry","category-old-blog","tag-php","tag-234","tag-252"],"_links":{"self":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=229"}],"version-history":[{"count":0,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/229\/revisions"}],"wp:attachment":[{"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}