I have a custom objects which will have user information fields and password fields.
Also i have custom LWC (salesforce site) with Username and password. Password has to store in encrypt value.
For Password Encryption I'm using Crypto.generateAesKey.
//Data to encrypt
Blob data = Blob.valueOf(pwd);
//Generate an AES key for the encryption.
Blob cryptoValue = Crypto.generateAesKey(256);
//Encrypt the data
Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoValue, data);
system.debug('encryptedData' + encryptedData );
String encryptedDataText = EncodingUtil.base64Encode(encryptedData);
But the problem is, Each time for the same string I'm getting new encrypted data.
For Ex: String ='123'
First Time encrypted data ==> WFxOkecVPKd/5AKVgHIdQVSVeyTOjbKQ/VrTo/M43+Hg+kSFqB4yycGyfXJptfnP
For the same string I'm getting different encrypted data uZpw7mGyJmBT7d/p0yHsJGYg46SdqrLMJg8BDApNukROz+U/p5QmdwIJQbl9hOm7
Can you please help, what is the Right way to generate and store the encrypted password.