diff options
author | rsiddharth <s@ricketyspace.net> | 2020-09-06 22:04:33 -0400 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2020-09-06 22:04:33 -0400 |
commit | 52f09ad3da9d8d11abef07c85179ac52b5bed842 (patch) | |
tree | 277dbff233a2c3aef26f182b65d95f676522cfc5 | |
parent | c16fc07b988aac8217fa16c912e460e994ae2363 (diff) |
lib: add FixedXORBytes
* lib/xor.go (FixedXORBytes): New function.
-rw-r--r-- | lib/xor.go | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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 := "" |