Компьютеры

Материал из VirtualIreland.ru.

Перейти к: навигация, поиск

Содержание

Как и положено, начнем с приветствия

(взято от сюда)

/*
 * Print's "Hello world\n" to stdout.
 *
 * How it works:  it generates strings of randomly selected letters,
 * spaces and newline characters and computes the MD5 checksum of
 * each string.  Once it get's a string whose MD5 checksum matches
 * the MD5 checksum of "Hello world\n", it prints the string and
 * terminates.
 *
 * N.B. This program uses the standard srandom and random functions to
 * generate the random strings.  Make sure that your implementation of
 * these functions has sufficient entropy to give you a decent chance
 * of generating the "Hello world\n" string!
 */

/*
 * md5data is a routine which computes the MD5 checksum of
 * the specified data bytes and returns the 16-byte checksum
 * into the 4 element  array csum.
 * Many MD5 implementations are available on the 'net.  Pick your
 * favourite one (or use the one in the md5 hash function node) and
 * write an interface routine for it called md5data which takes
 * the parameters described below.
 */

extern void md5data( void *data, int length, int csum[] );

/*
 * pre-computed MD5 checksum of "Hello world\n"
 */

int md5[4] = { 0xf0ef7081, 0xe1539ac0, 0x0ef5b761, 0xb4fb01b3 };

main()
{
    srandom(0);
    while (1) {
        char msg[13];
        int tmp[4];
        int i;
        for ( i = 0; i < 12; i += 1 ) {
            msg[i] =
            "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ \n"[
            random() % (2 * 26 + 2)
            ];
        }
        msg[12] = '\0';
        md5data(msg,strlen(msg),tmp);
        if ( md5[0] == tmp[0]
        &&   md5[1] == tmp[1]
        &&   md5[2] == tmp[2]
        &&   md5[3] == tmp[3] ) {
            write(1,msg,strlen(msg));
            exit(0);
        }
    }
}

или смотрим здесь полный список как это сказать (:

программирование

Soft

Hard

Просмотры
Личные инструменты