function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tulasi ram 1tulasi ram 1 

what is the best practice to store username and password in visualforce login page

Hi,

There is a Login page implemented using visualforce pages. How to save Username and Password when user sets the check box as True. What is the best practice to follow ande where we can save those credentials. Please help me on this.
Raj VakatiRaj Vakati
store then as a encrypted values .. using salesforce platform encryption .. Its the safe way 

If you use any other values you could able to see the values ... 

 
PawanKumarPawanKumar
You create one custom object UNPWD and do not give any field access(FLS) access including you admin. so even the admin user will not be able to query the encrypted data using SOQL. This way I have protected the data for one of my use case.

For encryption, you can use the following code.

-----------------------

Blob cryptoKey = Crypto.generateAesKey(256);
Blob data = Blob.valueOf('Test data to encrypted');
Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
Blob decryptedData = Crypto.decryptWithManagedIV('AES256', cryptoKey, encryptedData);
 
// Decode the decrypted data for subsequent use
 String decryptedDataString = decryptedData.toString();
 System.debug('decryptedDataString:'+decryptedDataString);

-----------------------

Please mark it best if it helps you. Thanks.

Regards,
Pawan Kumar