Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
liyanboy74 committed Apr 9, 2024
1 parent fc75f0c commit 5a630da
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -768,31 +768,15 @@ public static byte[] StringToByteArray(string hex)
.ToArray();
}

// FNV-1a (64-bit) non-cryptographic hash function.
// Adapted from: http://github.com/jakedouglas/fnv-java
public ulong HashFNV1a(byte[] bytes)
{
const ulong fnv64Offset = 14695981039346656037;
const ulong fnv64Prime = 0x100000001b3;
ulong hash = fnv64Offset;

for (var i = 0; i < bytes.Length; i++)
{
hash = hash ^ bytes[i];
hash *= fnv64Prime;
}

return hash;
}

UInt16 KEELOQ_NROUNDS = 528;
UInt32 NLF_LOOKUP_CONSTANT = 0x3a5c742e;
const UInt16 KEELOQ_NROUNDS = 528;
const UInt32 NLF_LOOKUP_CONSTANT = 0x3a5c742e;

public UInt16 nlf(UInt16 d)
{
return (UInt16)(((UInt32)(NLF_LOOKUP_CONSTANT) >> d) & 0x1);
}

/*
public UInt32 keeloq_encrypt(UInt64 key, UInt32 plaintext, UInt16 nrounds)
{
UInt32 ciphertext;
Expand All @@ -817,6 +801,7 @@ public UInt32 keeloq_encrypt(UInt64 key, UInt32 plaintext, UInt16 nrounds)
}
return ciphertext;
}
*/

public UInt32 keeloq_decrypt(UInt64 key, UInt32 ciphertext, UInt16 nrounds)
{
Expand Down

0 comments on commit 5a630da

Please sign in to comment.