main
Robert 1 month ago
parent 01d0138f43
commit 0606c3bea8
  1. 6
      src/Framework/MoneyFormatter.php
  2. 26
      src/Framework/Security.php

@ -218,6 +218,12 @@ class MoneyFormatter
return $ret; return $ret;
} }
public static function isInputDecimalMoney($value) {
$matches = preg_match('/^\s*(?=.*[1-9])\d*(?:\.\d{1,2})?\s*$/', $value);
$decimal = found_string($value, '.');
return ($matches > 0 && $decimal) ? true : false;
}
public static function getLocaleFromCode(string $currencyCode = "USD", string $locale = "en_US"): ?string public static function getLocaleFromCode(string $currencyCode = "USD", string $locale = "en_US"): ?string
{ {
if ($currencyCode === "USD" && $locale === "en_US") { if ($currencyCode === "USD" && $locale === "en_US") {

@ -27,6 +27,32 @@ class Security
use \IOcornerstone\Framework\Trait\Security\CsrfTokenFunctions; use \IOcornerstone\Framework\Trait\Security\CsrfTokenFunctions;
use \IOcornerstone\Framework\Trait\Security\SessionHijackingFunctions; use \IOcornerstone\Framework\Trait\Security\SessionHijackingFunctions;
public static function generatePassword(int $length = 12): string
{
$lowercase = 'abcdefghijklmnopqrstuvwxyz';
$uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$numbers = '0123456789';
$symbols = '@_%^()-+'; // $&*!" are INVALID to te shell!
$allCharacters = $lowercase . $uppercase . $numbers . $symbols;
if ($length < 2) {
$length = 2;
}
// Build password with required character types
$password = '';
$password .= $numbers[random_int(0, strlen($numbers) - 1)];
$password .= $symbols[random_int(0, strlen($symbols) - 1)];
// Fill remaining with random characters
for ($i = 2; $i < $length; $i++) {
$password .= $allCharacters[random_int(0, strlen($allCharacters) - 1)];
}
// Shuffle to randomize positions
return str_shuffle($password);
}
public static function hexPWD(int $bytes = 16): string public static function hexPWD(int $bytes = 16): string
{ {
$r = new RandomEngine(); $r = new RandomEngine();

Loading…
Cancel
Save