Since things didn't work out between me and mbedtls, here are the basic encryption algorithms.
xor.h@0:65a36a7b25d0, 2018-11-10 (annotated)
- Committer:
- priyanshu_varshney
- Date:
- Sat Nov 10 20:11:01 2018 +0000
- Revision:
- 0:65a36a7b25d0
Simple encryption algorithms apart from mbedtls(not working)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
priyanshu_varshney | 0:65a36a7b25d0 | 1 | #include <iostream> |
priyanshu_varshney | 0:65a36a7b25d0 | 2 | |
priyanshu_varshney | 0:65a36a7b25d0 | 3 | string encryptDecrypt(string toEncrypt) { |
priyanshu_varshney | 0:65a36a7b25d0 | 4 | char key[3] = {'K', 'C', 'Q'}; |
priyanshu_varshney | 0:65a36a7b25d0 | 5 | string output = toEncrypt; |
priyanshu_varshney | 0:65a36a7b25d0 | 6 | |
priyanshu_varshney | 0:65a36a7b25d0 | 7 | for (int i = 0; i < toEncrypt.size(); i++) |
priyanshu_varshney | 0:65a36a7b25d0 | 8 | output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; |
priyanshu_varshney | 0:65a36a7b25d0 | 9 | |
priyanshu_varshney | 0:65a36a7b25d0 | 10 | return output; |
priyanshu_varshney | 0:65a36a7b25d0 | 11 | } |