Files
.github
admin
docs
install
pages_template
qrcode
scan
system
autoload
PEAR2
mail
Admin.php
App.php
Balance.php
Csrf.php
File.php
Hookers.php
Http.php
Lang.php
Log.php
Message.php
Mikrotik.php
Package.php
Paginator.php
Parsedown.php
Password.php
Text.php
Timezone.php
User.php
Validator.php
index.html
cache
controllers
devices
lan
paymentgateway
plugin
uploads
vendor
.htaccess
api.php
boot.php
composer.json
composer.lock
cron.php
cron_reminder.php
index.html
orm.php
updates.json
ui
.gitignore
.htaccess_firewall
CHANGELOG.md
Dockerfile
LICENSE
README.md
composer.json
config.sample.php
docker-compose.example.yml
favicon.ico
index.php
init.php
radius.php
update.php
version.json
mitrobill/system/autoload/Password.php
2024-08-07 11:10:43 +07:00

51 lines
1.3 KiB
PHP

<?php
/**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux
**/
class Password
{
public static function _crypt($password)
{
return sha1($password);
}
public static function _verify($user_input, $hashed_password)
{
if (sha1($user_input) == $hashed_password) {
return true;
}
return false;
}
public static function _uverify($user_input, $hashed_password)
{
if ($user_input == $hashed_password) {
return true;
}
return false;
}
public static function _gen()
{
$pass = substr(str_shuffle(str_repeat('ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@#!123456789', 8)), 0, 8);
return $pass;
}
/**
* verify CHAP password
* @param string $realPassword
* @param string $CHAPassword
* @param string $CHAPChallenge
* @return bool
*/
public static function chap_verify($realPassword, $CHAPassword, $CHAPChallenge){
$CHAPassword = substr($CHAPassword, 2);
$chapid = substr($CHAPassword, 0, 2);
$result = hex2bin($chapid) . $realPassword . hex2bin(substr($CHAPChallenge, 2));
$response = $chapid . md5($result);
return ($response != $CHAPassword);
}
}