summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-09-06 14:53:53 -0400
committerrsiddharth <s@ricketyspace.net>2020-09-06 14:53:53 -0400
commitc16fc07b988aac8217fa16c912e460e994ae2363 (patch)
treef4d82d00257df192873b957a3eb112958bafde74 /lib
parent4168c23c8f0f4a2043a65e75d4f8ebe808d8b341 (diff)
lib: add TransposeBlocks
* lib/blocks.go (TransposeBlocks): New function.
Diffstat (limited to 'lib')
-rw-r--r--lib/blocks.go17
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
+}