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
Sanu VermaSanu Verma 

Decrypt the Password field

I want to Decrypt the password of Contact portal. But In my Code Unrecognized based 64 :* error. i did that things 1st tym thts why didnt understand what is the main problem. maybe my code is wrong or somethings else. plzz help me out...

this is my code which i tried to decrypt the password field
static void decryptPass(){
        List<Customer_Community_Details__c> portal=new List<Customer_Community_Details__c>([SELECT Id, Password1__c From Customer_Community_Details__c]);
        List<User> users=[SELECT Id, Name ,UserRole.Name FROM User WHERE UserRole.Name = 'Sales Support' OR UserRole.Name = 'Customer Support'];
        
        for(Customer_Community_Details__c portals : portal)
        {
        if(users !=Null){
           Blob cryptoKey = Crypto.generateAesKey(256);
           Blob data = EncodingUtil.base64Decode(portals.Password1__c);
           Blob decryptedData = Crypto.decryptWithManagedIV('AES128', cryptoKey , data);
           String dryptData = decryptedData.toString();
            
           System.debug('Printing dryptData '+dryptData);
            portals.Password1__c=dryptData;
            
        }
        }
        
        
    }

 
 
SandhyaSandhya (Salesforce Developers) 
Hi,

Refer below link which has the solution with BestAnswer for similar requirement.

https://developer.salesforce.com/forums/?id=906F0000000AE3dIAG
 
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya