init
This commit is contained in:
commit
897272d7c1
5 changed files with 167 additions and 0 deletions
23
bcrypt/working/shifts.py
Normal file
23
bcrypt/working/shifts.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
from typing import Any
|
||||
|
||||
def clamp_pos(x: int):
|
||||
return x if x > 0 else 0
|
||||
|
||||
def lpad(x: Any, n: int, pad: chr = ' '):
|
||||
x = str(x)
|
||||
return clamp_pos(n - len(x))*pad + x
|
||||
|
||||
def debug_R(B: int):
|
||||
# B = int('1'*7, 2)
|
||||
for j in range(8):
|
||||
j_sq = j**2
|
||||
R_j = B << j_sq
|
||||
lpadbin_R_j = lpad(bin(R_j)[2:], 64, pad='0')
|
||||
print(f'{lpad(j_sq, 2)}: {lpadbin_R_j} {R_j}')
|
||||
|
||||
def main():
|
||||
B = int(input('B: '), 2)
|
||||
debug_R(B)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue