458,155 Members | 1,773 Online Need help? Post your question and get tips & solutions from a community of 458,155 IT Pros & Developers. It's quick & easy.

# C Code for cryptographic algorithm

 P: 1 i have a problem... i have to seperate numbers from digits. For example i have a cryptographic code done which gives me the output as 2_three_06_one_01_four_32_two_3 I need to seperate the numbers and print them like it should be 2 6 13 23 Oct 30 '15 #1
6 Replies

 Expert Mod 5K+ P: 9,197 Can't you just read your input a byte at a time and check whether the byte value is between 49 and 57 on the ascii table.? or pass your byte to isdigit()? Oct 30 '15 #2

 P: 16 char rawdata[]="2_three_01_six" int i = 0 while i

 Expert 100+ P: 2,418 @jaseel97 you need to print some separator (space, new line, etc) between numbers. Oct 31 '15 #4

 Expert Mod 5K+ P: 9,197 @jaseel97: It worked for me. Of course, I had to fix the code errors but the logic flow is correct. Oct 31 '15 #5

 P: 29 Try This code Expand|Select|Wrap|Line Numbers #include #include using namespace std; // find gcd int gcd(int a, int b) {    int t;    while(1) {       t= a%b;       if(t==0)       return b;       a = b;       b= t;    } } int main() {    //2 random prime numbers    double p = 13;    double q = 11;    double n=p*q;//calculate n    double track;    double phi= (p-1)*(q-1);//calculate phi    //public key    //e stands for encrypt    double e=7;    //for checking that 1 < e < phi(n) and gcd(e, phi(n)) = 1; i.e., e and phi(n) are coprime.    while(e

 P: 25 In case the reader is new to programming the following is a process that has been used for many years. For C++, if your input is a std::string, or if you convert your input into a std::string, then parse it for what you want. Use the result of your parsing. Study std::string, and parsing, and go from there. Jun 5 '20 #7 