add renew
This commit is contained in:
@@ -9,6 +9,7 @@ from string import ascii_lowercase
|
||||
from docs.scripts.utils import render_markdown_template, emojis
|
||||
from src.models import NKodePolicy, KeypadSize
|
||||
from src.nkode_api import NKodeAPI
|
||||
from src.user_cipher import UserCipher
|
||||
from src.utils import select_keys_with_passcode_values
|
||||
|
||||
def display_keypad(icons_array: np.ndarray, props_per_key: int) -> str:
|
||||
@@ -65,6 +66,17 @@ if __name__ == "__main__":
|
||||
login_keypad = api.get_login_keypad(username, customer_id)
|
||||
selected_keys_login = select_keys_with_passcode_values(passcode_property_indices, login_keypad,
|
||||
keypad_size.props_per_key)
|
||||
|
||||
old_props = customer.cipher.property_key.copy()
|
||||
old_pos = customer.cipher.position_key.copy()
|
||||
customer.cipher.property_key = np.random.choice(2 ** 16, size=keypad_size.total_props, replace=False)
|
||||
customer.cipher.position_key = np.random.choice(2 ** 16, size=keypad_size.props_per_key, replace=False)
|
||||
new_props = customer.cipher.property_key
|
||||
new_pos = customer.cipher.position_key
|
||||
props_xor = new_props ^ old_props
|
||||
pos_xor = new_pos ^ old_pos
|
||||
user = customer.users[username]
|
||||
new_user_cipher = UserCipher.create(keypad_size, customer.cipher.position_key, policy.max_nkode_len)
|
||||
context = {
|
||||
"max_nkode_len": policy.max_nkode_len,
|
||||
"numb_of_keys": keypad_size.numb_of_keys,
|
||||
@@ -89,5 +101,15 @@ if __name__ == "__main__":
|
||||
"selected_keys": selected_keys_login,
|
||||
"login_keypad": display_keypad(login_keypad, keypad_size.props_per_key),
|
||||
"ordered_keys": login_keypad.reshape(-1, keypad_size.props_per_key)[selected_keys_login],
|
||||
"old_props": old_props,
|
||||
"new_props": new_props,
|
||||
"old_pos": old_pos,
|
||||
"new_pos": new_pos,
|
||||
"xor_props": props_xor,
|
||||
"xor_pos": pos_xor,
|
||||
"inter_user_position": user.cipher.combined_position_key ^ pos_xor,
|
||||
"inter_user_property_key": user.cipher.property_key ^ props_xor,
|
||||
"new_user_position": new_user_cipher.combined_position_key,
|
||||
"new_user_property_key": new_user_cipher.property_key,
|
||||
}
|
||||
render_markdown_template(Path("../templates/encipher_decipher_nkode.template.md"), Path("../encipher_decipher_nkode.md"), context)
|
||||
render_markdown_template(Path("../templates/encipher_decipher_renew_nkode.template.md"), Path("../encipher_decipher_renew_nkode.md"), context)
|
||||
|
||||
Reference in New Issue
Block a user