The hSecurity.php helper in Osclass provides a set of functions designed to enhance the security of your application. It includes utilities for generating random passwords, creating and validating CSRF tokens, checking for banned IPs or emails, encrypting and decrypting alert messages, and more.
osc_genRandomPassword($length = 8) – Creates a random password.
osc_csrf_token_form() – Generates a CSRF token for form submissions.
osc_csrf_token_url() – Generates a CSRF token for URLs.
osc_csrf_check($enabled = true) – Checks the validity of the CSRF token and handles errors if invalid.
osc_is_banned($email = '', $ip = null) – Determines if an email or IP address is banned.
osc_is_ip_banned($ip, $rules = null) – Checks if the provided IP address is banned based on the configured rules.
osc_is_email_banned($email, $rules = null) – Checks if the provided email is banned based on the configured rules.
osc_is_username_blacklisted($username) – Verifies if a username is blacklisted.
osc_verify_password($password, $hash) – Verifies a plaintext password against its hashed value.
osc_hash_password($password) – Hashes a plaintext password using the bcrypt algorithm.
osc_encrypt_alert($alert) – Encrypts an alert message using a generated key.
osc_decrypt_alert($string) – Decrypts an encrypted alert message.
osc_set_alert_public_key() – Sets the alert public key in the session.
osc_get_alert_public_key() – Retrieves the alert public key from the session.
osc_set_alert_private_key() – Sets the alert private key in the session.
osc_get_alert_private_key() – Retrieves the alert private key from the session.
osc_random_string($length) – Generates a random string of a specified length.