Step-by-Step implementation of the SHA-256 algorithm in Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
word_length = 32 | |
message_schedule = [str(full_message[i:i+word_length]) for i in range(0, len(full_message), word_length)] | |
for i in range(16, 64): | |
time.sleep(2) | |
clear_output(wait=True) | |
word1 = message_schedule[i - 2] | |
word2 = message_schedule[i - 7] | |
word3 = message_schedule[i - 15] | |
word4 = message_schedule[i - 16] | |
print('Loop #%i' % (i - 16)) | |
print('Pos ' + str(i - 16).zfill(2) + ': ' + message_schedule[i - 16] + ' > word4\t = ' + word4) | |
print('Pos ' + str(i - 15).zfill(2) + ': ' + message_schedule[i - 15] + ' > sigma0(word3) = ' + bin(int(sigma0(word3), 2))[2:].zfill(32)) | |
print('Pos ' + str(i - 14).zfill(2) + ': ' + message_schedule[i - 14]) | |
print('Pos ' + str(i - 13).zfill(2) + ': ' + message_schedule[i - 13]) | |
print('Pos ' + str(i - 12).zfill(2) + ': ' + message_schedule[i - 12]) | |
print('Pos ' + str(i - 11).zfill(2) + ': ' + message_schedule[i - 11]) | |
print('Pos ' + str(i - 10).zfill(2) + ': ' + message_schedule[i - 10]) | |
print('Pos ' + str(i - 9).zfill(2) + ': ' + message_schedule[i - 9]) | |
print('Pos ' + str(i - 8).zfill(2) + ': ' + message_schedule[i - 8]) | |
print('Pos ' + str(i - 7).zfill(2) + ': ' + message_schedule[i - 7] + ' > word2\t = ' + word2) | |
print('Pos ' + str(i - 6).zfill(2) + ': ' + message_schedule[i - 6]) | |
print('Pos ' + str(i - 5).zfill(2) + ': ' + message_schedule[i - 5]) | |
print('Pos ' + str(i - 4).zfill(2) + ': ' + message_schedule[i - 4]) | |
print('Pos ' + str(i - 3).zfill(2) + ': ' + message_schedule[i - 3]) | |
print('Pos ' + str(i - 2).zfill(2) + ': ' + message_schedule[i - 2] + ' > sigma1(word1) = '+ bin(int(sigma1(word1), 2))[2:].zfill(32)) | |
print('Pos ' + str(i - 1).zfill(2) + ': ' + message_schedule[i - 1]) | |
new_word = ( \ | |
int(sigma1(word1), 2) + \ | |
int(word2, 2) + \ | |
int(sigma0(word3), 2) + \ | |
int(word4, 2)) & \ | |
int('11111111111111111111111111111111', 2) | |
print() | |
print('\t\t\t\t\t\t AND 11111111111111111111111111111111') | |
print() | |
print('\t\t\t\t\t\tnew word = ' + bin(new_word)[2:].zfill(32)) | |
message_schedule.append(bin(new_word)[2:].zfill(32)) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, i got message that this notebook is invalid. I can not open it in jupyter.
Thanks for your help!
Edit: now I put the lines manually in jupyter but after loop #47 i got following message:
Can you fix it please? Thanks