现代计算机可以计算多少个 SHA256 哈希值?

发布于 2024-10-13 00:02:23 字数 344 浏览 3 评论 0原文

我想知道破解基于不同字符集的哈希所需的数学时间。

例如,仅使用 7 个字母的 US-ASCII 字母字符,我们就知道可以使用 267 种可能的序列。了解计算机每分钟可以生成多少个这样的哈希值,可以让我了解生成所有可能的哈希值并破解某个 7 字符哈希值(生日攻击除外)需要多长时间。

例如,以上面的数字为例,如果现代四核每分钟可以生成 100 万个哈希值,则需要 8031810176 / 1000000 / 60 = 133.86 小时才能找到该范围内的所有可能的哈希值。

另外,具有原生 AES 的新 Sandy Bridge Intel 芯片如何发挥作用?

I want to know the mathematical time required for cracking hashes based off different sets of characters.

For example, using only 7 letter, US-ASCII alphabetic characters we know that there are 267 possible sequences that could be used. Knowing how many of these could be generated by a computer each minute would give me an idea of how long it would take to generate all possible hashes and crack a certain 7 character hash (birthday attacks aside).

For example, taking the number above, if a modern quad core could generate 1 million hashes each minute it would take 8031810176 / 1000000 / 60 = 133.86 hours to find all possible hashes in that range.

Also, how does the new Sandy Bridge Intel chips with native AES play into this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

む无字情书 2024-10-20 00:02:23

我使用 OpenSSL SHA256 实现用 C 语言编写了此测试。

#include <stdio.h>
#include <string.h>
#include "openssl/sha.h"

// http://stackoverflow.com/questions/4764608/generate-all-strings-under-length-n-in-c/4764686#4764686
int inc(char *str) {
    if (!str[0]) return 0;

    if (str[0] == 'z') {
        str[0] = 'a';
        return inc(str + sizeof(char));
    }

    str[0]++;
    return 1;
}

unsigned char buffer[65];
char* hashstring(char *str, int len) {
    char hash[SHA256_DIGEST_LENGTH]; // the openssl hash
    SHA256_CTX sha256;
    int i; // counter

    SHA256_Init(&sha256);
    SHA256_Update(&sha256, str, len);
    SHA256_Final(hash, &sha256);

    for (i = 0; i < SHA256_DIGEST_LENGTH; i++) {
        sprintf(buffer + (i * 2), "%02x", hash[i]); // convert openssl hash to mortal human string
    }

    return buffer;
}

int main(int argc, char *argv[]) {
    int N = 4; // max length string
    char str[N+1]; // the string holder
    int i; // counter

    unsigned int tot = 0; // number of hashes calculated

    for (i = 0; i < N; i++) str[i] = 'a';
    str[N] = 0;

    do {
        hashstring(str, N);
        tot++;
    } while(inc(str));

    printf("%d\n", tot);
}

编译:

gcc -lcrypto -O3 -o test test.c

结果(我知道,我对计算机名称不太有创意):

nightcracker@nightcracker-pc:~/c/sha256$ time ./test
11881376

real    3m2.431s
user    3m2.335s
sys 0m0.008s

所以这是每秒 11881376 / 182.4 = 65139 哈希值。那么计算所有哈希值需要 26^7/101821/3600 = 34 小时。请注意,所有这些都是在 Q6600 四核 CPU 上的单线程应用程序中完成的,并且不包括将哈希值写入文件。

编辑

糟糕,我正在计算包​​含 N 个字符及以下的字符串的所有哈希值。已更正并更新数据。

I wrote this test in C using the OpenSSL SHA256 implementation.

#include <stdio.h>
#include <string.h>
#include "openssl/sha.h"

// http://stackoverflow.com/questions/4764608/generate-all-strings-under-length-n-in-c/4764686#4764686
int inc(char *str) {
    if (!str[0]) return 0;

    if (str[0] == 'z') {
        str[0] = 'a';
        return inc(str + sizeof(char));
    }

    str[0]++;
    return 1;
}

unsigned char buffer[65];
char* hashstring(char *str, int len) {
    char hash[SHA256_DIGEST_LENGTH]; // the openssl hash
    SHA256_CTX sha256;
    int i; // counter

    SHA256_Init(&sha256);
    SHA256_Update(&sha256, str, len);
    SHA256_Final(hash, &sha256);

    for (i = 0; i < SHA256_DIGEST_LENGTH; i++) {
        sprintf(buffer + (i * 2), "%02x", hash[i]); // convert openssl hash to mortal human string
    }

    return buffer;
}

int main(int argc, char *argv[]) {
    int N = 4; // max length string
    char str[N+1]; // the string holder
    int i; // counter

    unsigned int tot = 0; // number of hashes calculated

    for (i = 0; i < N; i++) str[i] = 'a';
    str[N] = 0;

    do {
        hashstring(str, N);
        tot++;
    } while(inc(str));

    printf("%d\n", tot);
}

Compile:

gcc -lcrypto -O3 -o test test.c

And results (I know, I'm not very creative with computernames):

nightcracker@nightcracker-pc:~/c/sha256$ time ./test
11881376

real    3m2.431s
user    3m2.335s
sys 0m0.008s

So that's 11881376 / 182.4 = 65139 hashes per second. Then it's 26^7/101821/3600 = 34 hours to compute all the hashes. Please note, all of this was done on a Q6600 quad-core CPU in a single-threaded application and excluded writing the hashes to file.

EDIT

Woops, I was calculating all the hashes of strings with N characters and below. Corrected and data updated.

流心雨 2024-10-20 00:02:23

请记住,GPU 的散列速度比 CPU 快 50 倍到 100 倍。编程更困难,但效率更高。请参阅 www.bitcointalk.com 了解数字。我知道我在 Radeon HD5830 上每秒执行 6.22 亿次 SHA-256。

Remember that a GPU can hash 50x - 100x faster than a CPU. Its harder to program, but more efficient. See www.bitcointalk.com for numbers. I know I do 622 million SHA-256's per sec on a Radeon HD5830.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文