4 Answers
4

Note that no matter if you are using an internal or external call, in order to decrypt something on-chain, you have to give the miners the private key, which is obviously not so private anymore. That is the reason why encryption is hardly implementable in open blockchains like Ethereum.

You can certainly do what you want to do, but it would make no sense whatsoever.

Using very simple commands on the Ethereum node's RPC, any person with access to any node could see the clear text sent to the encryptData function. Yes, you could write Solidity code to encrypt the text on-chain, but it would have already been sent through a very public interface.

It would be very much better to encrypt the text prior to sending it and storing the encrypted text on-chain.

Probably the reason why you're not finding any information on this topic is because it doesn't work.