Since things didn't work out between me and mbedtls, here are the basic encryption algorithms.

guide.txt

Committer:
priyanshu_varshney
Date:
2018-11-10
Revision:
0:65a36a7b25d0

File content as of revision 0:65a36a7b25d0:

>>>> Xor Encryption
XOR encryption (or Exclusive-OR encryption) is a common method of encrypting text into a format that cannot be trivially cracked by the average person. XOR encryption is great for storing things like game save data, and other data types that are stored locally on a users computer, that while not a big deal if they are tampered with, you would like to deter people from doing so. XOR encryption is also used often as a part of more complex encryption algorithms.

The idea behind it is that if you don't know the original character or the XOR encryption key, it is impossible to determine what either one is. However, the reason that it is not entirely secure is that data almost always contains patterns (JSON uses '{' and '}' characters, XML contains plenty of '<' and '>' characters, etc.) so if someone is able to determine the pattern and unlock even one character, they will have the key to unlocking everything else.

However secure or insecure XOR encryption really is, it has plenty of valid use cases. Any kind of deterrent added to data that you don't want users to tamper with but that they will have easy access to is a prime candidate, so long as security isn't paramount.

The concept is simple, you define a key character, and for every character in the string you want to encrypt, you apply the key. Once you want to unencrypt the encrypted data, you simply go through the string and apply the key again.

---------------------------------------------
>>>> RSA ENCRYPTION

>> Generating Public Key :
Select two prime no's. Suppose P = 53 and Q = 59.
Now First part of the Public key  : n = P*Q = 3127.

 We also need a small exponent say e : 
But e Must be 

An integer.

Not be a factor of n.
 
1 < e < Φ(n) [Φ(n) is discussed below], 
Let us now consider it to be equal to 3.    
Our Public Key is made of n and e

>> Generating Private Key :

We need to calculate Φ(n) :
Such that Φ(n) = (P-1)(Q-1)     
      so,  Φ(n) = 3016

    
Now calculate Private Key, d : 
d = (k*Φ(n) + 1) / e for some integer k
For k = 2, value of d is 2011.
Now we are ready with our – Public Key ( n = 3127 and e = 3) and Private Key(d = 2011)
>> Example
Now we will encrypt “HI” :

Convert letters to numbers : H  = 8 and I = 9

    
Thus Encrypted Data c = 89e mod n. 
Thus our Encrypted Data comes out to be 1394


Now we will decrypt 1394 : 
    
Decrypted Data = cd mod n. 
Thus our Encrypted Data comes out to be 89

8 = H and I = 9 i.e. "HI".