I am wondering how is should i implement one-time pad encryption in my code.
I use 16-byte pages at the moment, and the implementation in Golang from the page: https://github.com/ryanuber/go-otp/blob/master/otp.go (line 83 is the Encrypt()
method).
However, the data i need to encrypt sometimes (not always) is larger than 16 byte.
// Page must be at least as long as plain text
if len(page) < len(payload) {
return nil, fmt.Errorf("otp: insufficient page size")
}
result := make([]byte, len(payload))
for i := 0; i < len(payload); i++ {
plainText := int(payload[i])
secretKey := int(page[i]) // ln 95
cipherText := (plainText + secretKey) % 255
result[i] = byte(cipherText)
}
What i did is commented out the page length check, so encryption now ignores the length problem; using modulus while indexing page
(line 95):
secretKey := int(page[i % len(page)])
So, if i encrypt data buffer say of 10 megabytes, is it still secure, and if not, why?