summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--challenge/c05.go2
-rw-r--r--lib/hex.go5
2 files changed, 4 insertions, 3 deletions
diff --git a/challenge/c05.go b/challenge/c05.go
index 7f22663..96f0893 100644
--- a/challenge/c05.go
+++ b/challenge/c05.go
@@ -15,7 +15,7 @@ var key string = "ICE"
func C5() {
es := lib.RepeatingXOR(icebaby, key)
- hs := lib.BytesToHexStr([]byte(es))
+ hs := lib.AsciiStrToHexStr(es)
fmt.Printf("RepeatingXOR('%v', '%v') = %v\n", icebaby, key, hs)
}
diff --git a/lib/hex.go b/lib/hex.go
index 5b1741f..0087f33 100644
--- a/lib/hex.go
+++ b/lib/hex.go
@@ -54,12 +54,13 @@ func ByteToHexStr(b byte) string {
return s
}
-func BytesToHexStr(bs []byte) string {
+func AsciiStrToHexStr(as string) string {
hs := ""
- if len(bs) < 1 {
+ if len(as) < 1 {
return hs
}
+ bs := []byte(as)
for i := 0; i < len(bs); i++ {
hs += ByteToHexStr(bs[i])
}