diff options
author | rsiddharth <s@ricketyspace.net> | 2020-09-06 14:53:53 -0400 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2020-09-06 14:53:53 -0400 |
commit | c16fc07b988aac8217fa16c912e460e994ae2363 (patch) | |
tree | f4d82d00257df192873b957a3eb112958bafde74 | |
parent | 4168c23c8f0f4a2043a65e75d4f8ebe808d8b341 (diff) |
lib: add TransposeBlocks
* lib/blocks.go (TransposeBlocks): New function.
-rw-r--r-- | lib/blocks.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/blocks.go b/lib/blocks.go index 3805d86..e817e6f 100644 --- a/lib/blocks.go +++ b/lib/blocks.go @@ -30,3 +30,20 @@ func BreakIntoBlocks(cb []byte, keysize int) [][]byte { } return blocks } + +func TransposeBlocks(blocks [][]byte, keysize int) [][]byte { + if len(blocks) < 1 { + return make([][]byte, 0) + } + + tblocks := make([][]byte, keysize) + for i := 0; i < len(blocks); i++ { + for j := 0; j < len(blocks[i]); j++ { + if len(tblocks[j]) == 0 { + tblocks[j] = make([]byte, len(blocks)) + } + tblocks[j][i] = blocks[i][j] + } + } + return tblocks +} |