summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-09-06 22:07:20 -0400
committerrsiddharth <s@ricketyspace.net>2020-09-06 22:07:20 -0400
commit3ed79ba77f5110cf901ccd469d9e40244c97279c (patch)
treef00be423193cdacbbb7b0f52ebb15528566ec62d
parentd17694275a0b0051a8e763b6867767b4986bfd7d (diff)
lib: update XORCrackSingleKey
* lib/brute.go (XORCrackSingleKey): Simplify function; use FillBytes and FixedXORBytes
-rw-r--r--lib/brute.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/brute.go b/lib/brute.go
index 54be06b..5210df1 100644
--- a/lib/brute.go
+++ b/lib/brute.go
@@ -15,15 +15,15 @@ func XORCrackSingleKey(hs string) (byte, string, float64) {
var scr float64 = 100.0
i := byte(0)
+ as := []byte(HexStrToAsciiStr(hs))
for i < 255 {
- ks := FillStr(ByteToHexStr(i), l)
- xs := FixedXOR(hs, ks)
- as := HexStrToAsciiStr(xs)
+ ks := FillBytes(i, l)
+ xs := FixedXORBytes(as, ks)
- s := phraseScore(as)
+ s := phraseScore(string(xs))
if s < scr {
k = i
- ds = as
+ ds = string(xs)
scr = s
}
i += 1