Simple ASCII Encryption in C

This C program demonstrates a basic encryption technique by incrementing the ASCII value of each character in a string. The `encrypt` function modifies the input string, and the main function displays the encrypted result.
mail@pastecode.io avatar
unknown
c_cpp
a month ago
275 B
6
Indexable
Never
#include <stdio.h>

void encrypt(char str[]) {
    for (int i = 0; str[i] != '\0'; i++) {
        str[i] = str[i] + 1; // Increment ASCII value by 1
    }
}

int main() {
    char str[] = "()";
    encrypt(str);
    printf("Encrypted string: %s\n", str);
    
    return 0;
}
Leave a Comment