当前位置: 首页>>代码示例>>C++>>正文


C++ TheMatrix::CountUnmix方法代码示例

本文整理汇总了C++中TheMatrix::CountUnmix方法的典型用法代码示例。如果您正苦于以下问题:C++ TheMatrix::CountUnmix方法的具体用法?C++ TheMatrix::CountUnmix怎么用?C++ TheMatrix::CountUnmix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TheMatrix的用法示例。


在下文中一共展示了TheMatrix::CountUnmix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char* argv[])
{

    if (argc<4) {
        printf("usage: %s foundkey bitpos framecount (framecount2 burst2)\n", argv[0]);
        return -1;
    }

    unsigned framecount = 0;
    uint64_t stop;
    sscanf(argv[1],"%lux",&stop);
    int pos;
    sscanf(argv[2],"%i",&pos);
    Bidirectional back;
    TheMatrix tm;
    back.doPrintCand(false);
    sscanf(argv[3],"%i",&framecount);

    uint64_t stop_val = Bidirectional::ReverseBits(stop);
    printf("#### Found potential key (bits: %i)####\n", pos);
    stop_val = back.Forwards(stop_val, 100, NULL);
    back.ClockBack( stop_val, 101+pos );
    uint64_t tst;
    unsigned char bytes[16];
    char out[115];
    out[114]='\0';
    int x = 0;
    printf("Framecount is %i\n", framecount);

    unsigned framecount2 = -1;
    if (argc>=6) {
	if (strlen(argv[5]) != 114) {
		fprintf(stderr, "burst2 must be a 114 digit bitstring\n");
		exit(1);
	}
        sscanf(argv[4],"%i",&framecount2);
    }

    while (back.PopCandidate(tst)) {
        uint64_t orig = tm.CountUnmix(tst, framecount);
        orig = tm.KeyUnmix(orig);
        printf("KC(%i): ", x);
        for(int i=7; i>=0; i--) {
            printf("%02x ",(unsigned)(orig>>(8*i))&0xff);
        }
        x++;

        if (framecount2>=0) {
            uint64_t mix = tm.KeyMix(orig);
            mix = tm.CountMix(mix,framecount2);
            mix = back.Forwards(mix, 101, NULL);
            back.Forwards(mix, 114, bytes);
            int ok = 0;
            for (int bit=0;bit<114;bit++) {
                int byte = bit / 8;
                int b = bit & 0x7;
                int v = bytes[byte] & (1<<(7-b));
                char check = v ? '1' : '0';
                if (check==argv[5][bit]) ok++;
            }
            if (ok>104) {
                printf(" *** MATCHED ***");
            } else {
                printf(" mismatch");
            }
        }

        printf("\n");

#if 0
        uint64_t mixed = back.Forwards(tst, 101, NULL);
        back.Forwards(mixed, 114, bytes);
        for (int bit=0;bit<114;bit++) {
            int byte = bit / 8;
            int b = bit & 0x7;
            int v = bytes[byte] & (1<<(7-b));
            out[bit] = v ? '1' : '0';
        }
        printf("cipher %s\n", out);
#endif
    }
}
开发者ID:0x0d,项目名称:kraken,代码行数:82,代码来源:find_kc.cpp


注:本文中的TheMatrix::CountUnmix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。