What are some best practices for securely hashing data in PHP for payment processing, especially when using services like Postfinance?

When securely hashing data in PHP for payment processing, especially when using services like Postfinance, it is important to use strong hashing algorithms like SHA-256 and to salt the data before hashing to prevent rainbow table attacks. Additionally, always ensure that the hashed data is transmitted securely over HTTPS to protect it from interception.

// Generate a random salt
$salt = openssl_random_pseudo_bytes(16);

// Combine the data with the salt and hash using SHA-256
$hashed_data = hash('sha256', $data . $salt);

// Transmit the hashed data securely over HTTPS