Encrypt file

    0

    2

    Giovanny Gongora

    Codiga's C Recipes
    #include<stdio.h>
    #include<conio.h>
    
    int main(){
      char fname[20], ch;
      FILE *fps, *fpt;
      printf("Enter Filename: ");
      gets(fname);
      fps = fopen(fname, "r");
      if(fps == NULL)
        return 0;
      fpt = fopen("temp.txt", "w");
      if(fpt == NULL)
        return 0;
      ch = fgetc(fps);
      while(ch != EOF){
        ch = ch+100;
        fputc(ch, fpt);
        ch = fgetc(fps);
      }
      fclose(fps);
      fclose(fpt);
      fps = fopen(fname, "w");
      if(fps == NULL)
        return 0;
      fpt = fopen("temp.txt", "r");
      if(fpt == NULL)
        return 0;
      ch = fgetc(fpt);
      while(ch != EOF){
        ch = fputc(ch, fps);
        ch = fgetc(fpt);
      }
      fclose(fps);
      fclose(fpt);
      printf("\nFile %s Encrypted Successfully!", fname);
      getch();
      return 0;
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.