If you want it to be simple and security is not a big concern (since Javascript ... observation in the comments), the easiest way would be to simply create any random value larger (more digits) than the number and a simple XOR with number. It is assumed that the key (= random number) will be previously transferred to another program.
1. generate random number with 10 hex digits -> KEY 2. take the number then do (number XOR key ) -> result 3. send result 4. get the result and do (result XOR key) -> number
something better (stronger) would be to use any system of public and private keys. The exchange keys, crypts with the public on one side, are decrypted with closed keys on the other side.
source share