Skip to content

Commit

Permalink
Merge pull request #5 from vibbits/encodingfix
Browse files Browse the repository at this point in the history
Fix encoding/decoding of signatures.
lducazu authored May 23, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 9721a07 + 76b497c commit 5e8c1ef
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions irdata/signatures.py
Original file line number Diff line number Diff line change
@@ -22,8 +22,8 @@
"""

import base64
import hashlib
import re
from hashlib import sha1

strip_regexp = re.compile("[^A-Z0-9]")

@@ -76,7 +76,9 @@ def make_signature(sequence, legacy=0):

if legacy:
sequence = normalise_sequence(sequence)
return base64.b64encode(sha1(sequence).digest())[:-1]
digest = hashlib.sha1(sequence.encode("utf-8")).digest()
b64enc = base64.b64encode(digest)[:-1]
return b64enc.decode("utf-8")


def process_file(f, out, column, separator=",", append=0, append_length=0, legacy=0):
@@ -99,7 +101,7 @@ def process_file(f, out, column, separator=",", append=0, append_length=0, legac
true value. This is not recommended.
"""

for line in f.xreadlines():
for line in f.readlines():
columns = line.rstrip("\n").split("\t")
inputs = columns[column].split(separator)
signatures = fix_signatures(inputs)

0 comments on commit 5e8c1ef

Please sign in to comment.