summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/xor.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/xor.go b/lib/xor.go
index 0d1f3d7..7b57d82 100644
--- a/lib/xor.go
+++ b/lib/xor.go
@@ -22,6 +22,18 @@ func FixedXOR(a, b string) string {
return cs
}
+func FixedXORBytes(as, bs []byte) []byte {
+ if len(as) != len(bs) {
+ return make([]byte, 0)
+ }
+
+ cs := make([]byte, len(as))
+ for i := 0; i < len(as); i++ {
+ cs[i] = as[i] ^ bs[i]
+ }
+ return cs
+}
+
// Both 'data' and 'key' need to be plain ascii string.
func RepeatingXOR(data, key string) string {
xs := ""