how this encrypt function can be made more secure and also increase it strength against reverse engineering?

QByteArray password(12, Qt::Uninitialized);
QByteArray data = "test";
encrypt(data, password);
		
/*
	The password is generated inside the function with the pre defined size
    of the byteArray i.e: 
        QByteArray pass(20, Qt::Uninitialized);

	will create a random password of size 20.
	The bytearray size must be multiple of 4 or it will not fit the base64 encoding.

	The salt is also generated inside the function with a random size between 16 and 21.
	It also generates a random string to prepend to the data with a random size between 6 and 11.

    The data is returned as:
	[prependStr][salt][iv][encryptedData]
*/
inline bool encrypt(QByteArray& data, QByteArray& b64Password)
{
    // Generate the password with the pre-defined size of the byteArray
    unsigned char randomByte;
    RAND_bytes(&randomByte, 1);
    int passwordSize = (b64Password.size() * 3) / 4;  // Inverse of base64 encoding ratio
    std::vector<unsigned char> password(passwordSize);
    RAND_bytes(password.data(), passwordSize);

    // Generate random salt
    RAND_bytes(&randomByte, 1);
    int saltSize = 16 + (randomByte % 6); // Random size between 16 and 21
    std::vector<unsigned char> salt(saltSize);
    RAND_bytes(salt.data(), saltSize);

    // Use PBKDF2 for key derivation
    std::vector<unsigned char> key(32);
    std::vector<unsigned char> iv(12);  // 12 bytes for GCM
    if (PKCS5_PBKDF2_HMAC(reinterpret_cast<const char*>(password.data()), password.size(),
                          salt.data(), salt.size(),
                          100000, EVP_sha256(),
                          key.size(), key.data()) != 1) {
        return false;
    }
    RAND_bytes(iv.data(), iv.size());

    // Encode the password as base64
    BIO* bio = BIO_new(BIO_s_mem());
    BIO* b64 = BIO_new(BIO_f_base64());
    bio = BIO_push(b64, bio);
    BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
    BIO_write(bio, password.data(), password.size());
    BIO_flush(bio);
    BUF_MEM* bptr;
    BIO_get_mem_ptr(bio, &bptr);
    b64Password = QByteArray(bptr->data, bptr->length);
    BIO_free_all(bio);

    // Initialize encryption (using AES-256-GCM)
    EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();
    if (!ctx) return false;

    if (EVP_EncryptInit_ex(ctx, EVP_aes_256_gcm(), nullptr, key.data(), iv.data()) != 1) {
        EVP_CIPHER_CTX_free(ctx);
        return false;
    }

    // Encrypt
    std::vector<unsigned char> encryptedData(data.size() + EVP_CIPHER_block_size(EVP_aes_256_gcm()));
    int encryptedLength = 0;

    if (EVP_EncryptUpdate(ctx, encryptedData.data(), &encryptedLength, 
                          reinterpret_cast<const unsigned char*>(data.constData()), data.size()) != 1) {
        EVP_CIPHER_CTX_free(ctx);
        return false;
    }

    int finalLength = 0;
    if (EVP_EncryptFinal_ex(ctx, encryptedData.data() + encryptedLength, &finalLength) != 1) {
        EVP_CIPHER_CTX_free(ctx);
        return false;
    }

    encryptedLength += finalLength;
    encryptedData.resize(encryptedLength);

    // Get the authentication tag
    std::vector<unsigned char> tag(16);
    if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, 16, tag.data()) != 1) {
        EVP_CIPHER_CTX_free(ctx);
        return false;
    }

    EVP_CIPHER_CTX_free(ctx);

    // Generate random string to prepend
    RAND_bytes(&randomByte, 1);
    int prependStrSize = 6 + (randomByte % 6); // Random size between 6 and 11
    std::vector<unsigned char> prependStr(prependStrSize);
    RAND_bytes(prependStr.data(), prependStrSize);

    // Combine all parts
    std::vector<unsigned char> result;
    result.reserve(prependStr.size() + salt.size() + iv.size() + encryptedData.size() + tag.size());
    result.insert(result.end(), prependStr.begin(), prependStr.end());
    result.insert(result.end(), salt.begin(), salt.end());
    result.insert(result.end(), iv.begin(), iv.end());
    result.insert(result.end(), encryptedData.begin(), encryptedData.end());
    result.insert(result.end(), tag.begin(), tag.end());

    // Base64 encode
    bio = BIO_push(BIO_new(BIO_f_base64()), BIO_new(BIO_s_mem()));
    BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
    BIO_write(bio, result.data(), result.size());
    BIO_flush(bio);
    BIO_get_mem_ptr(bio, &bptr);

	OPENSSL_cleanse(data.data(), data.size());

    data = QByteArray(bptr->data, bptr->length);
    BIO_free_all(bio);

    // Securely erase sensitive data
    OPENSSL_cleanse(password.data(), password.size());
    OPENSSL_cleanse(key.data(), key.size());
    OPENSSL_cleanse(salt.data(), salt.size());
    OPENSSL_cleanse(iv.data(), iv.size());
    OPENSSL_cleanse(encryptedData.data(), encryptedData.size());
    OPENSSL_cleanse(tag.data(), tag.size());
    OPENSSL_cleanse(result.data(), result.size());

    return true;
}