⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cryptstring.c

📁 并行算法实验用的源代码
💻 C
字号:
/******************************************************************** File:        cryptString.c Program use: Crypt Lab #:       3********************************************************************//*******************************Function:    cryptString Description: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXInput:       string: string to be encrypted or decrypted             key:    the used for decoding or encoding the string             n:      n is a constant for all the key values                     a strings for this project. Do not                     change or alter the value of n.Output:      After encryption/decryption has been performed,             the new string is returned. ********************************/char* cryptString (char *string,                unsigned long int key,               unsigned long int n              ){  unsigned long int msg, pmsg;  unsigned      int char0, char1, char2;  char              *newStr;                int x, i;   msg = 0;  newStr = (char*)malloc(sizeof(char) * strlen(string));  for(x = 0; x < strlen(string); x = x + 2){        char0 = string[x];    char1 = string[x+1];    msg = (( char0       & ((1 << 1 * 8) - 1))          |((char1 << 8) & ((1 << 2 * 8) - 1))          );    pmsg = msg;    for(i = 1; i < key; i++){      msg = (msg * pmsg) % n;    }    newStr[x]   = (  msg       & ( (1 << (1 * 8)) - 1) );    newStr[x+1] = ( (msg >> 8) & ( (1 << (2 * 8)) - 1) );  }return(newStr);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -