Skip to content

Commit

Permalink
fix: not working yet
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Jun 16, 2023
1 parent 1ca559e commit 9c37647
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/kasa_crypt/_crypt_impl.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ cdef char* _encrypt(const char *unencrypted):
return encrypted

def encrypt(string: str) -> bytes:
return _encrypt(string.encode('ascii'))
return _encrypt(string.encode('utf-8'))


def decrypt(string: bytes) -> str:
return _decrypt(string).decode('ascii')
return _decrypt(string).decode('utf-8')
4 changes: 2 additions & 2 deletions src/kasa_crypt/crypt_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
void _encrypt_into(const char * unencrypted, char * encrypted) {
uint8_t unencrypted_byte;
uint8_t key = 171;
for(unsigned i = 0; i < strlen(unencrypted); i++) {
for(unsigned i = 0; i <= strlen(unencrypted); i++) {
unencrypted_byte = unencrypted[i];
key = key ^ unencrypted_byte;
encrypted[i] = key;
Expand All @@ -18,7 +18,7 @@ void _decrypt_into(const char * encrypted, char * unencrypted) {
uint8_t unencrypted_byte;
uint8_t encrypted_byte;
uint8_t key = 171;
for(unsigned i = 0; i < strlen(encrypted); i++) {
for(unsigned i = 0; i <= strlen(encrypted); i++) {
encrypted_byte = encrypted[i];
unencrypted_byte = key ^ encrypted_byte;
key = encrypted_byte;
Expand Down

0 comments on commit 9c37647

Please sign in to comment.