ScrapExplorer - main.c

Home / usr / XORenc Lines: 3 | Size: 1076 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1/* SPDX-License-Identifier: GPL-3.0 2 * XORenc 3 * 4 * main.c 5 * 6 * COPYRIGHT NOTICE 7 * Copyright (C) 2024-2025 0x4248 and contributors 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the license is not changed. 10 * 11 * This software is free and open source. Licensed under the GNU general 12 * public license version 3.0 as published by the Free Software Foundation. 13 */ 14 15#include <stdio.h> 16 17char *encode(char *str, int *key) 18{ 19 /** 20 * Loop over each item in input string (str) and XOR it with the key using 21 * the modulo operator to get the correct index of the key. 22 * 23 * If we hit \0 we are at the end of the string and we can stop. 24 */ 25 for (int i = 0; str[i] != '\0'; i++) 26 { 27 str[i] = str[i] ^ key[i % 4]; 28 } 29 return str; 30} 31 32int main() 33{ 34 char str[100]; 35 int key[100]; 36 37 /* input */ 38 printf("Enter a string: "); 39 scanf("%s", str); 40 printf("Enter a key: "); 41 scanf("%d", key); 42 43 /* Encrypt */ 44 encode(str, key); 45 printf("%s\n", str); 46 47 /* Decrypt */ 48 encode(str, key); 49 printf("%s\n", str); 50 return 0; 51}
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.