# What is the conventional way to encrypt double/float data accurately?

Basically, i want to encrypt standard ecg data with resolution of 11 bit mostly come from MIT-BIH Arrhythmia Database. The sample point values i saw are decimal like .

Suppose that i just want to do simple xor encryption with a set of random generated integer number. How do i accomplish xor of double/float with these integer number?

• I already tried by converting the sample point and the random number into 64 bit binary according to ieee754 standard, but there will be a case of the resulting xor values will be NaN (too big or too smal values with all 1 in exponent part) hence i cant get the float value or plot the encrypted data(because NaN is not a value) to visualize the signal before and after encryption.
• I also already thought of converting the double/float into integers first by multiplying it by 10^N and floor it down but i dont know what is the appropriate N for all ecg data cases because i might have data loss for some sample point cases such as 0.0009823 with N=100 will become 0. I had hunch that to determine the appropriate N depends on the resolution of the ecg data but after reading some related literature i still dont found the answer.

So what i would like to know is what is the best approaches?and what is the most conventional way of encrypting double/float value of ecg data like that?

• What are you trying to visualize after encryption? Encrypted data generally looks random, so there's little value in plotting it Commented Nov 13, 2020 at 13:12
• i would like to visually see how big is the difference between encrypted data and the plaintext data and also i would like to calculate the encrypted data histogram, coefficient correlation, and information entropy Commented Nov 13, 2020 at 13:24
• You've got 64/32-bit (double/float respectively) binary data in. You bitwise XOR that with the random value. You get a random 64/32-bit value out. out, it might not be a valid floating point number (could be ±INF or a NAN). Treat it all as unsigned integers, use that to take the statistics you're interested in. Commented Nov 13, 2020 at 14:13
• Your first approach is the best approach. Encrypted data isn't supposed to be able to be graphed. Do you want to weaken the encryption so that you can graph it? Commented Nov 13, 2020 at 20:40
• @MuhammadFauzi encryption encrypts bytes, not floats. Did you consider drawing a histogram of the bytes? Commented Nov 14, 2020 at 18:53