Inspiration

This project was inspired by the MLH daily challenge given to encrypt a password

What it does

It encrypts and decrypts a given password for the user

#include <stdio.h>

int main()
{
    int i, x;
    char str[100];

    printf("\nPlease enter your password for encryption:\t");
    gets(str);

    printf("\nPlease choose following options:\n");
    printf("1 = Encrypt the password.\n");
    printf("2 = Decrypt the password.\n");
    scanf("%d", &x);
    switch (x)
    {
    case 1:
        for (i = 0; (i < 100 && str[i] != '\0'); i++)
            str[i] = str[i] + 7;

        printf("\nEncrypted password: %s\n", str);
        break;

    case 2:
        for (i = 0; (i < 100 && str[i] != '\0'); i++)
            str[i] = str[i] - 7;

        printf("\nDecrypted password: %s\n", str);
        break;

    default:
        printf("\nError\n");
    }
    return 0;
}

Built With

Share this project:

Updates