Apex Crypto And Decrypto Class

public class EncryptAndDecryptHelper {
    
    public static String encriptString(Blob key, String data){
        try{
            Blob bdata = Blob.valueOf(data);
            Blob encrypted = Crypto.encryptWithManagedIV('AES128', key, bdata);
            return  EncodingUtil.base64Encode(encrypted); 
        }catch(Exception e){
            system.debug('exception'+e.getMessage());
            return '';
        }
        
    }
    public static String decryptString(Blob key, String decryptString){
        try{
            Blob DecodedEncryptedBlob = EncodingUtil.base64Decode(decryptString);
            Blob decryptedB = Crypto.decryptWithManagedIV('AES128',key, DecodedEncryptedBlob);
            return decryptedB.toString();   
        }catch(Exception e){
            system.debug('exception'+e.getMessage());
            return '';
        }
         
    }
    
}

Ranjith T [03/09/2019]