Question: I need help to convert this C program to CUDA gpu please #include stdio.h #include string.h #include math.h void crypt(char *password, char *salt, char *encryptedPassword)

I need help to convert this C program to CUDA gpu please

#include "stdio.h" #include "string.h" #include "math.h"

void crypt(char *password, char *salt, char *encryptedPassword) { int i; long hash; char hashmap; char *p,*s; encryptedPassword[15]='\0';

p = password; hash=199; // prime numbers are our friend while (*p != '\0') { hash = hash*3 + (*p); p++; }

p = password; s = salt; for (i=0; i<15; i++) { hash = hash*7 + (*p) + (*s); hashmap = (hash % 94) + 33; // range of printable ASCII chars encryptedPassword[i] = hashmap; p++; if (*p == '\0') p=password; s++; if (*s == '\0') s=salt; }

}

void intToString(int num, char *s) { int ones = (num) % 26; int twentySix = (num / 26) % 26; int twentySixSquared = (num / 26 / 26) % 26; int twentySixCubed = (num / 26 / 26 / 26) % 26; int twentySixFourth = (num / 26 / 26 / 26 / 26) % 26; int twentySixFifth = (num / 26 / 26 / 26 / 26 / 26) % 26;

int i = 0; s[i++] = twentySixFifth + 'A'; s[i++] = twentySixFourth + 'A'; s[i++] = twentySixCubed + 'A'; s[i++] = twentySixSquared + 'A'; s[i++] = twentySix + 'A'; s[i++] = ones + 'A'; s[i] = '\0'; }

int stringToInt(char *s) { int length = strlen(s); int sum = 0; int power = 0;

for (int i = length-1; i >= 0; i--) { int digit = s[i] - 'A'; sum += digit * pow(26,power); power++; } return sum; }

int main() { char salt[3]; char password[9]; char encryptedPassword[16]; char encryptedGuess[16];

strcpy(salt,"XY"); // Our salt is just the fixed string XY

printf("Welcome to the brute force password cracker. "); printf("Enter a six-letter password in all upper-case letters: "); int n = scanf("%s",password);

crypt(password, salt, encryptedPassword); int num = stringToInt(password); printf("Using salt %s, your pasword maps to the encrypted password of: %s ", salt, encryptedPassword); printf("Mapped to a number, %s is %d ",password,num);

printf("Working on cracking the encryption by trying all password combinations... ");

for (int i = 0; i < 26*26*26*26*26*26; i++) { intToString(i, password); crypt(password, salt, encryptedGuess); if (!strcmp(encryptedPassword, encryptedGuess)) { printf("CRACKED! The password is: %s ", password); break; }

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!