summaryrefslogtreecommitdiffstats
path: root/enc
diff options
context:
space:
mode:
Diffstat (limited to 'enc')
-rw-r--r--enc/b64.go24
-rw-r--r--enc/hex.go26
-rw-r--r--enc/xor.go22
3 files changed, 0 insertions, 72 deletions
diff --git a/enc/b64.go b/enc/b64.go
deleted file mode 100644
index 4c251a2..0000000
--- a/enc/b64.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright © 2020 rsiddharth <s@ricketyspace.net>
-// SPDX-License-Identifier: ISC
-
-package enc
-
-const b64_table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
-
-func HexToBase64(hex string) string {
- hb := []byte(hex)
-
- b64 := ""
- for i := 0; i <= len(hb)-3; i = i + 3 {
- a := (HexCharToDec(hb[i])<<8 |
- HexCharToDec(hb[i+1])<<4 |
- HexCharToDec(hb[i+2]))
- b64 += encode(a >> 6)
- b64 += encode(a & 0b111111)
- }
- return b64
-}
-
-func encode(b uint16) string {
- return string(b64_table[b])
-}
diff --git a/enc/hex.go b/enc/hex.go
deleted file mode 100644
index a1b9b46..0000000
--- a/enc/hex.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright © 2020 rsiddharth <s@ricketyspace.net>
-// SPDX-License-Identifier: ISC
-
-package enc
-
-// Adapted from
-// https://go.googlesource.com/go/+/refs/tags/go1.15/src/encoding/hex/hex.go#83
-func HexCharToDec(c byte) uint16 {
- switch {
- case '0' <= c && c <= '9':
- return uint16(c - '0')
- case 'a' <= c && c <= 'f':
- return uint16(c - 'a' + 10)
- }
- return 0
-}
-
-func DecToHexChar(i uint16) byte {
- switch {
- case 0 <= i && i <= 9:
- return byte(48 + i)
- case 10 <= i && i <= 15:
- return byte(97 + (i - 10))
- }
- return 0
-}
diff --git a/enc/xor.go b/enc/xor.go
deleted file mode 100644
index fe412b2..0000000
--- a/enc/xor.go
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright © 2020 rsiddharth <s@ricketyspace.net>
-// SPDX-License-Identifier: ISC
-
-package enc
-
-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
-}