From e18ab2b384546e496784c6f2669c21cdaf43e777 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Fri, 27 Oct 2023 13:31:50 -0700 Subject: [PATCH] initial commits --- README.md | 44 +++++++++++++++++--- enc/bytes/encodeuint16.go | 20 +++++++++ encodeuint16.go => enc/runes/encodeuint16.go | 7 ++-- 3 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 enc/bytes/encodeuint16.go rename encodeuint16.go => enc/runes/encodeuint16.go (72%) diff --git a/README.md b/README.md index 4543087..363cad4 100644 --- a/README.md +++ b/README.md @@ -144,15 +144,30 @@ mostSignificant, leastSignificant := hexadecarunes.EncodeByte(value, runesymbols To hexadecimal encode a `uint16` use any of these: ```go -import "sourcecode.social/reiver/go-hexadeca" +import "sourcecode.social/reiver/go-hexadeca/enc/bytes" // ... -r3, r2, r1, r0 := hexadeca.EncodeUint16UsingLowerCaseSymbols(value) +r3, r2, r1, r0 := hexadecabytes.EncodeUint16UsingLowerCaseSymbols(value) // ... -r3, r2, r1, r0 := hexadeca.EncodeUint16UsingUpperCaseSymbols(value) +r3, r2, r1, r0 := hexadecabytes.EncodeUint16UsingUpperCaseSymbols(value) + +``` + +Or: + +```go +import "sourcecode.social/reiver/go-hexadeca/enc/runes" + +// ... + +r3, r2, r1, r0 := hexadecarunes.EncodeUint16UsingLowerCaseSymbols(value) + +// ... + +r3, r2, r1, r0 := hexadecarunes.EncodeUint16UsingUpperCaseSymbols(value) ``` @@ -160,17 +175,34 @@ Or: ```go import ( - "sourcecode.social/reiver/go-hexadeca" + "sourcecode.social/reiver/go-hexadeca/enc/bytes" + "sourcecode.social/reiver/go-hexadeca/symbols/byte" +) + +// ... + +r3, r2, r1, r0 := hexadecabytes.EncodeUint16(value, bytesymbols.LowerCase) + +// ... + +r3, r2, r1, r0 := hexadecabytes.EncodeUint16(value, bytesymbols.UpperCase) +``` + +Or: + +```go +import ( + "sourcecode.social/reiver/go-hexadeca/enc/bytes" "sourcecode.social/reiver/go-hexadeca/symbols/rune" ) // ... -r3, r2, r1, r0 := hexadeca.EncodeUint16(value, runesymbols.LowerCase) +r3, r2, r1, r0 := hexadecabytes.EncodeUint16(value, runesymbols.LowerCase) // ... -r3, r2, r1, r0 := hexadeca.EncodeUint16(value, runesymbols.UpperCase) +r3, r2, r1, r0 := hexadecabytes.EncodeUint16(value, runesymbols.UpperCase) ``` ## hexadecimal encode `uint32` diff --git a/enc/bytes/encodeuint16.go b/enc/bytes/encodeuint16.go new file mode 100644 index 0000000..695c898 --- /dev/null +++ b/enc/bytes/encodeuint16.go @@ -0,0 +1,20 @@ +package hexadecabytes + +import ( + "sourcecode.social/reiver/go-hexadeca/symbols/byte" +) + +func EncodeUint16(value uint16, symbolFunc func(byte)byte) (r3 byte, r2 byte, r1 byte, r0 byte) { + r3, r2 = EncodeByte(byte(0x00ff & (value >> (8 ))), symbolFunc) + r1, r0 = EncodeByte(byte(0x00ff & value ), symbolFunc) + + return +} + +func EncodeUint16UsingLowerCaseSymbols(value uint16) (r3 byte, r2 byte, r1 byte, r0 byte) { + return EncodeUint16(value, bytesymbols.LowerCase) +} + +func EncodeUint16UsingUpperCaseSymbols(value uint16) (r3 byte, r2 byte, r1 byte, r0 byte) { + return EncodeUint16(value, bytesymbols.UpperCase) +} diff --git a/encodeuint16.go b/enc/runes/encodeuint16.go similarity index 72% rename from encodeuint16.go rename to enc/runes/encodeuint16.go index 4251661..d535139 100644 --- a/encodeuint16.go +++ b/enc/runes/encodeuint16.go @@ -1,13 +1,12 @@ -package hexadeca +package hexadecarunes import ( - "sourcecode.social/reiver/go-hexadeca/enc/runes" "sourcecode.social/reiver/go-hexadeca/symbols/rune" ) func EncodeUint16(value uint16, symbolFunc func(byte)rune) (r3 rune, r2 rune, r1 rune, r0 rune) { - r3, r2 = hexadecarunes.EncodeByte(byte(0x00ff & (value >> (8 ))), symbolFunc) - r1, r0 = hexadecarunes.EncodeByte(byte(0x00ff & value ), symbolFunc) + r3, r2 = EncodeByte(byte(0x00ff & (value >> (8 ))), symbolFunc) + r1, r0 = EncodeByte(byte(0x00ff & value ), symbolFunc) return }