<?php
/**
 * Hashing utilities.
 *
 * @package flo-checkout
 */

declare( strict_types = 1 );

namespace Flo_Checkout\Gateways\Shift4_APM;

defined( 'ABSPATH' ) || exit;

/**
 * Class Hashing
 */
class Hashing {

	/**
	 * Generate an SHA-256 hash.
	 *
	 * @param string $data Data to hash.
	 * @param string $secret Secret key.
	 *
	 * @return string
	 */
	public static function hmac( string $data, string $secret ): string {
		$normalized_data = preg_replace( '/\r\n|\r|\n/', "\r\n", $data );
		return hash_hmac( 'sha512', $normalized_data, $secret );
	}
}
