Do you mean encoding should be rawdata := fmt.Print("%016d%s%s", len(s1), s1,s2) or rawdata := fmt.Printf("%016d%s%s", len(s1), s1,s2)
On Monday, March 13, 2023 at 4:36:50 PM UTC+2 Alex Howarth wrote: > You might be looking for strconv.ParseUint() > https://pkg.go.dev/strconv#ParseUint > > https://go.dev/play/p/qAO9LfLD41D > > On Mon, 13 Mar 2023 at 07:24, Van Fury <fury...@gmail.com> wrote: > >> >> Sorry I did not frame my question properly but what I would like to do is >> to >> encode concatenated s1 and s2 into raw binary and then decode the raw >> binary >> back to s1 and s2. >> >> >> On Friday, March 10, 2023 at 11:36:09 PM UTC+2 Alex Howarth wrote: >> >>> If s1 and s2 are a fixed length then you can just slice up the decoded >>> string based on the lengths. If they are of a variable length, you'll need >>> a separator in the input string to later split on when decoded (s3 := s1 + >>> ":" + s2 etc)? >>> >>> On Fri, 10 Mar 2023 at 10:33, Van Fury <fury...@gmail.com> wrote: >>> >>>> Hi, >>>> >>>> I have two hexadecimal string values and would like to concatenate the >>>> two strings and >>>> >>>> 1. encode the result to binary >>>> 2. decode the resulting binary back to hexadecimal string >>>> >>>> I did the following but I was finding it difficult to decode the result >>>> back. I ignore error check in this case. >>>> >>>> What i did so far: >>>> >>>> s1 := "1d28ed66824aa2593e1f2a4cf740343f" >>>> >>>> s2 := "dee2bd5dde763885944bc9d65419" >>>> >>>> s3 := s1 + s2 >>>> >>>> s1s2Byte, _ := hex.DecodeString(s3) >>>> >>>> randAutnBin := fmt.Sprintf("%b", s1s2Byte) >>>> >>>> result: >>>> >>>> [11101 101000 11101101 1100110 10000010 1001010 10100010 1011001 111110 >>>> 11111 101010 1001100 11110111 1000000 110100 111111 11011110 11100010 >>>> 10111101 1011101 11011110 1110110 111000 10000101 10010100 1001011 >>>> 11001001 >>>> 11010110 1010100 11001] >>>> >>>> I would like to decode the binary result back the hexadecimal string to >>>> get s1 and s2. >>>> >>>> Any help? >>>> >>>> Van >>>> >>>> -- >>>> >>> You received this message because you are subscribed to the Google >>>> Groups "golang-nuts" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to golang-nuts...@googlegroups.com. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/golang-nuts/ad3a981b-cf22-47cd-9fe6-8db83a097b42n%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/golang-nuts/ad3a981b-cf22-47cd-9fe6-8db83a097b42n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts...@googlegroups.com. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/1f66ccdc-6c58-48f0-9017-9614220f88d9n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/golang-nuts/1f66ccdc-6c58-48f0-9017-9614220f88d9n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8c1be24c-8056-4b74-ac79-e1f8ae7bf935n%40googlegroups.com.