• Log in or sign up for an account here: https://www.sythe.org/login

My cryptography function.

Joined
Jan 27, 2007
Sythe Gold
0
Messages
1,225
Location
/bin/sh
My cryptography function.
Yes, guys, I know it's newbie-stuff, I do NOT need any feedback. Thank you.
I just can't figure a way to reverse it.
Can anyone help? ^_^
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
/* Integers */
int charPos;
int plainlen;
int x = 0;
int a = 0;
int b = 0;
int random;
int i;
int y = 0;
int random1 = 0;
int z = 0;
int declen;
/* Character arrays (strings) */
char plaintext[100];
char encryptedtext[100];
/* Methods */
void encipher(char plain[]);
void decipher(char enc[]);
int string_length(char str[]);
/* End */

char block[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789!#¤%&/()=?";
char input[100];
int main(char* argv[]) {
    scanf ("%s",&plaintext) ;
    i = string_length(plaintext);
    encipher(plaintext);
    decipher(plaintext);
}
int string_length(char* plaintext) {
 return strlen(plaintext);
}
void encipher(char plain[]) {
       srand ( time(NULL) );

                   while(x < i) {

                                                       while(y < 8) {

                                                              while(z < 7) {
                                                                        random1 = rand() % 67 + 1;
                                                               printf("%c",block[random1]);
                                                                             z++;}  
                                                                              z = 0;            printf("%c",plaintext[x]);
                                                               y++;
                                                                     x++;
                                                               }
                                                         
                                                               }
                             
     }
void decipher(char enc[]) {
     declen = string_length(enc);
     plainlen = declen / 8;
       while(a < plainlen) {
               b = b + 8;
               printf("%c",enc[b]);
               }
              return;
              }
 
My cryptography function.
You can't reverse it since you've used the random number generator in part of the encryption.
 
Member of the Month Winner
Sythe's 10th Anniversary
My cryptography function.
Why can't I?
It's pretty much 1 character, then eight other (was it seven?).
I can reverse it manually when I see it.
if you use rand(), there is no way to tell what the number is once the string is encrypted, unless you keep a cache which is extremely insecure and inefficient.
 
My cryptography function.
if you use rand(), there is no way to tell what the number is once the string is encrypted, unless you keep a cache which is extremely insecure and inefficient.
Can't I just split the string in pieces or something?
Rand() is for determining which characters the next seven will be.
 
Member of the Month Winner
Sythe's 10th Anniversary
My cryptography function.
Can't I just split the string in pieces or something?
Rand() is for determining which characters the next seven will be.
If I'm understanding you correctly, this is a rather insecure way of doing things ...
 
My cryptography function.
Use keys, not just a random number gen.
 
My cryptography function.
If you want to waste about 100+ lines of code you could program an algorithm that calculates the number, you have to remember, not even computers are truly random..

Or

..Not sure, i havnt programmed in C++ in a lot of years, but i would suggest having a brute forcer that locks out after 10 attempts. That way it has to guess the number and only the one number can be bruted.. In all honesty, unless your doing it for practice this kind of cryptography is pretty much useless.
 
Runescape Gamblingrunescape gambling
Back
Top