Controller for PageA processes some data, then redirects to PageB along with some sensitive values. How can I safely pass these values to controller for PageB? i.e. cannot put them in PageReference.parameters as they will be visible to users.
if you have such requirement you can go for visualforce wizard where you can share controller properties between two different pages by defining same controller for both pages.
In that way there will be no need to passing your secure data. Here is the detail tutorial about this.
You can also use the crypto class to encrypt your data and send it through url parameter and decrypt again when required.
// Generate an AES key for the purpose of this sample. // Normally this key should be stored in a protected custom setting // or an encrypted field on a custom object Blob cryptoKey = Crypto.generateAesKey(256); // Generate the data to be encrypted. Blob data = Blob.valueOf('Test data to encrypted'); // Encrypt the data and have Salesforce.com generate the initialization vector Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
// Decrypt the data - the first 16 bytes contain the initialization vector Blob decryptedData = Crypto.decryptWithManagedIV('AES256', cryptoKey, encryptedData); // Decode the decrypted data for subsequent use String decryptedDataString = decryptedData.toString();