Thread: How does this encryption works?

  1. #1
    Registered User
    Join Date
    Dec 2022
    Posts
    4

    How does this encryption works?

    Actually i am confused.. what does the following code does ??
    what is ^ and %... What is control flow of the source code?
    Please explain line by line.



    Code:
    void encryptDecrypt(uint8_t *input, uint64_t size) {
        uint8_t key[] = {'A', 'B', 'C'}; //Can be any chars, and any size array
        
        for(int i = 0; i < size; i++) {
            input[i] = input[i] ^ key[i % (sizeof(key)/sizeof(uint8_t))];
        }
    }
    Thanks

  2. #2
    Registered User
    Join Date
    Feb 2022
    Location
    Canada, PEI
    Posts
    103
    A simple Google will answer this question.
    Operators in C

  3. #3
    Registered User
    Join Date
    Dec 2022
    Posts
    4
    Quote Originally Posted by G4143 View Post
    A simple Google will answer this question.
    Operators in C
    Could you please explain the source code in details?
    Each line by line the control flow!

  4. #4
    Registered User
    Join Date
    Feb 2022
    Location
    Canada, PEI
    Posts
    103
    Here's a link(again Google'ing xor encryption)...
    XOR Encryption Algorithm - 101 Computing

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code after while loop not being executed
    By dan108 in forum C Programming
    Replies: 8
    Last Post: 09-07-2013, 07:05 AM
  2. Implement a loop into my code?
    By CtrlAltElite in forum C++ Programming
    Replies: 6
    Last Post: 11-26-2011, 10:10 AM
  3. Loop code problem
    By Laika1986 in forum C Programming
    Replies: 12
    Last Post: 10-19-2011, 06:04 PM
  4. For Loop won't iterate to next bit of code.
    By acidblue in forum C Programming
    Replies: 5
    Last Post: 04-25-2010, 02:25 PM
  5. this is my code which is not performing the for loop!
    By wajeeha.javed in forum C++ Programming
    Replies: 9
    Last Post: 12-10-2006, 11:12 AM

Tags for this Thread