This question already has an answer here:

What is the best way to encrypt and decrypt a variable in Solidity so only the msg.sender and contract can see that variable?

marked as duplicate by eth Nov 20 '16 at 1:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Practical answer: You can't. If the contract can see it when it executes, everyone who has the blockchain can see it.

Theoretical answer that won't help you: Homomorphic encryption. See Can smart contracts compute on encrypted data?

Not the answer you're looking for? Browse other questions tagged or ask your own question.