Skip to content

Commit

Permalink
fix test, fix error on set key by its hash in python before 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Sets88 authored and Maxim Nikitenko committed Nov 14, 2024
1 parent 76b6eb3 commit 07cb344
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_requirements():

setup(
name='ssh-crypt',
version='1.1.11',
version='1.1.12',
license='BSD',
author='Maxim Nikitenko',
author_email='iam@sets88.com',
Expand Down
11 changes: 4 additions & 7 deletions ssh_crypt/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import binascii
from typing import Union, Optional

from paramiko import Agent
Expand Down Expand Up @@ -49,14 +48,12 @@ def get_first_key():

def find_filter_key(ssh_filter):
ssh_filter = ssh_filter.encode()
filter_keys = []

for key in [key for key in get_keys() if key[0].name in VALID_SSH_NAME]:
if ssh_filter in key[1]:
filter_keys.append(key)
elif ssh_filter in binascii.hexlify(key[0].get_fingerprint(), sep=":"):
filter_keys.append(key)
if filter_keys:
return filter_keys[0][0]
return key[0]
elif ssh_filter.replace(b':', b'') in key[0].get_fingerprint().hex().encode():
return key[0]


def choose_ssh_key(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_encrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ def test_decrypt_rsa(rsa_in_agent):
with tempfile.NamedTemporaryFile() as file_obj_encryptor:
with tempfile.NamedTemporaryFile("r") as file_obj_decryptor:
encryptor = Processor(
data_processor=encryptor,
data_processor=lambda: encryptor,
string_data=random_data,
output_file=file_obj_encryptor.name,
input_file=None,
)
encryptor.run()
decryptor = Processor(
data_processor=decryptor,
data_processor=lambda: decryptor,
string_data=None,
output_file=file_obj_decryptor.name,
input_file=file_obj_encryptor.name,
Expand Down

0 comments on commit 07cb344

Please sign in to comment.