app: restructure and start building p15 output

This commit is contained in:
Greg T. Wallace 2024-01-25 20:16:37 -05:00
parent 6610c92058
commit e2e4f2037c
24 changed files with 622 additions and 168 deletions
pkg/tools

32
pkg/tools/bitwise.go Normal file
View file

@ -0,0 +1,32 @@
package tools
// BitwiseComplimentOf returns the bitwise compliment of data
func BitwiseComplimentOf(data []byte) []byte {
compliment := []byte{}
for i := range data {
compliment = append(compliment, ^data[i])
}
return compliment
}
// IsBitwiseCompliment returns true if data1 and data2 are bitwise compliments,
// otherwise it returns false
func IsBitwiseCompliment(data1, data2 []byte) bool {
// if not same length, definitely not compliments
if len(data1) != len(data2) {
return false
}
// check each byte
for i := range data1 {
// if any byte is NOT the bitwise compliment of the matching byte in other data
// set, then the full set is not bitwise compliment and false
if data1[i] != ^data2[i] {
return false
}
}
return true
}