SuperMicro-IPMI-LicenseGene.../php-version/supermicro.php

35 lines
775 B
PHP
Raw Normal View History

2019-06-23 22:42:10 +08:00
<?php
class Supermicro {
2021-06-29 09:44:18 +02:00
const SUPERMICRO_OOB_PRIVATE_KEY_HEX = '8544E3B47ECA58F9583043F8';
/**
* @param string $BMC_MAC
* @return string
*/
public function getLicense(string $BMC_MAC, bool $source = false)
{
$key = $this->getKey($BMC_MAC);
return $source ? $key : implode(
' - ',
array_slice(
str_split(
$key, 4
), 0, 6
)
);
}
protected function getKey(string $BMC_MAC)
{
return hash_hmac(
'sha1',
hex2bin(
preg_replace(
'![^A-F0-9]!i', '', $BMC_MAC
)
), hex2bin(self::SUPERMICRO_OOB_PRIVATE_KEY_HEX)
);
}
2019-06-23 22:42:10 +08:00
}