Показаны сообщения с ярлыком криптография. Показать все сообщения
Показаны сообщения с ярлыком криптография. Показать все сообщения

Почему хэш-функции являются односторонними?

Let me invent a simple "password hashing algorithm" to show you how it works. Unlike the other examples in this thread, this one is actually viable, if you can live with a few bizarre password restrictions. Your password is two large prime numbers, x and y. For example:
x = 48112959837082048697
y = 54673257461630679457
You can easily write a computer program to calculate xy in O(N^2) time, where N is the number of digits in x and y. (Basically that means that it takes four times as long if the numbers are twice as long. There are faster algorithms, but that's irrelevant.) Store xy in the password database.
x*y = 2630492240413883318777134293253671517529
A child in fifth grade, given enough scratch paper, could figure out that answer. But how do you reverse it? There are many algorithms people have devised for factoring large numbers, but even the best algorithms are slow compared to how quickly you can multiply x by y. And none of those algorithms could be performed by a fifth grader, unless the numbers were very small (e.g., x=3, y=5).
That is the key property: the computation is much simpler going forwards than backwards. For many problems, you must invent a completely new algorithm to reverse a computation.
This has nothing to do with injective or bijective functions. When you are cracking a password, it often doesn't matter if you get the same password or if you get a different password with the same hash. The hash function is designed so it is hard to reverse it and get any answer at all, even a different password with the same hash. In crypto-speak: a hash function vulnerable to a preimage attack is utterly worthless. (The password hashing algorithm above is injective if you have a rule that x < y.)
What do cryptography experts do? Sometimes, they try to figure out new algorithms to reverse a hash function (pre-image). They do exactly what you say: analyze the algorithm and try to reverse it. Some algorithms have been reversed before, others have not.
Exercise for the reader: Suppose the password database contains the following entry:
3521851118865011044136429217528930691441965435121409905222808922963363310303627
What is the password? (This one is actually not too difficult for a computer.)
Footnote: Due to the small number of passwords that people choose in practice, a good password hash is not merely difficult to compute backwards but also time-consuming to compute forwards, to slow down dictionary attacks. As another layer of protection, randomized salt prevents the use of precomputed attack tables (such as "rainbow tables").
Footnote 2: How do we know that it is hard to reverse a hash function? Unfortunately, we don't. We just don't know any easy ways to reverse hash functions. Making a hash function that is provably difficult to reverse is the holy grail of hash function design, and it has not been achieved yet (perhaps it will never happen).

источник

Как пользоваться GPG

Просмотр списка ключей, когда их еще нет ни одного, выдает следующее:

$ gpg --list-keys
gpg: directory `/home/vasily/.gnupg' created
gpg: new configuration file `/home/vasily/.gnupg/gpg.conf' created
gpg: WARNING: options in `/home/vasily/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/vasily/.gnupg/pubring.gpg' created
gpg: /home/vasily/.gnupg/trustdb.gpg: trustdb created

$ ls -la ~/.gnupg/
total 56
drwx------  2 vasily vasily  4096 Aug 27 18:57 .
drwx------ 25 vasily vasily 12288 Aug 27 18:57 ..
-rw-------  1 vasily vasily  9398 Aug 27 18:57 gpg.conf
-rw-------  1 vasily vasily     0 Aug 27 18:57 pubring.gpg
-rw-------  1 vasily vasily    40 Aug 27 18:57 trustdb.gpg


error: Unable to find vcvarsall.bat

На Windows 10 + Python 3.5.1 при установке библиотеки simple-crypt с помощью pip:
$ ./pip install simple-crypt
может возникать следующая ошибка:
    error: Unable to find vcvarsall.bat

Причина этого несчастья в том, что что при установке не был найден компилятор C.

Можно не заморачиваться и взять готовый пакет отсюда (если он там есть конечно):

Всякие разные решения:


Шифрование информации в отсутствии компьютера

Принцип работы базового сокрытия информации в колоде