As a thought experiment, I was wondering what would be the best way to securely store some data on the blockchain. The data itself as an example could be some text, maybe a few kilobytes. Lets say I don't want anyone to know what that text is and since its on the blockchain, anyone can find and access it so encryption would likely be required. Is there any sort of best practice for this scenario? Lets say a whole system was built around the idea of storing small bits of text on the blockchain in a secure manner, would it be something you trust? It would be something not far off from a company having a database of encrypted sensitive info but everyone having access to that database. Ethical debates of using bitcoin as an arbitrary store of data aside, I am just curious how in this sort of environment you could guarantee the security and privacy of that data. To be clear I don't really care about the ethical hesitation against this, and I also am specifically only interested in what can be done on the bitcoin blockchain not others.
Can you elaborate a bit on your use case? I'm going to guess that the actual reason for wanting to write the data to Bitcoin's blockchain is not actual storage (there are plenty of distributed and centralized systems for storing data) but to have a sort of proof that the data is authentic/not tampered with? In that case you can simply hash the data and put that small hash in Bitcoin's blockchain using an OP_RETURN transaction. There are plenty of existing tools and libraries for doing that.
A few KBs of data would be prohibitively expensive to store on Bitcoin (and pretty much any altcoin worth its salt).