Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void to_encrypt() {
- char line[150], encrypted_line[150];
- int offset;
- printf("Enter encryption offset: ");
- scanf("%d", &offset);
- FILE *file = fopen("Test.txt", "r");
- FILE *encrypted_file = fopen("Test_Encrypted.txt", "w");
- if (file == NULL)
- printf("Failed to open file.");
- fgets(line, 150, file); /* testing to see if fgets() is reading the file*/
- printf("%s", line);
- while (fgets(line, 150, file)) {
- for (int c = 0; c <= (sizeof(line) / sizeof(line[0])); c++) {
- if (line[c] + offset >= 127) {
- encrypted_line[c] = 32 + ((line[c] + offset) - 127);
- } else {
- encrypted_line[c] = line[c] + offset;
- }
- }
- printf("%s", encrypted_line);
- fprintf(encrypted_file, "%s\n", encrypted_line);
- }
- fclose(file);
- fclose(encrypted_file);
- }
- void to_decrypt(void) {
- }
- int main() {
- to_encrypt();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement