summaryrefslogtreecommitdiffstats
path: root/lib/xor.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xor.go')
-rw-r--r--lib/xor.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/xor.go b/lib/xor.go
new file mode 100644
index 0000000..270999c
--- /dev/null
+++ b/lib/xor.go
@@ -0,0 +1,22 @@
+// Copyright © 2020 rsiddharth <s@ricketyspace.net>
+// SPDX-License-Identifier: ISC
+
+package lib
+
+func FixedXOR(a, b string) string {
+ cs := ""
+ if len(a) != len(b) {
+ return cs
+ }
+
+ ab := []byte(a)
+ bb := []byte(b)
+ for i := 0; i < len(ab); i++ {
+ p := HexCharToDec(ab[i])
+ q := HexCharToDec(bb[i])
+ r := DecToHexChar(p ^ q)
+
+ cs += string(r)
+ }
+ return cs
+}