I am having some trouble decrypting a string correctly. The first few bytes are not correct, the remaining characters are correct.
Encryption:
user := User{username, password, *rsakey, username_maca, password_maca}
u, _ := json.Marshal(user)
ciphertext := make([]byte, userlib.BlockSize+len(u))
iv := ciphertext[:userlib.BlockSize]
copy(iv, userlib.RandomBytes(userlib.BlockSize))
cipher := userlib.CFBEncrypter(password_byte, iv)
cipher.XORKeyStream(ciphertext[userlib.BlockSize:], []byte(u))
Decryption:
encryptd_data, valid := userlib.DatastoreGet(string(username_mac))
iv := encryptd_data[:userlib.BlockSize]
ciphertext := encryptd_data[userlib.BlockSize:]
cipher := userlib.CFBDecrypter(password_byte, iv)
cipher.XORKeyStream(ciphertext[userlib.BlockSize:], ciphertext[userlib.BlockSize:])
var g uuid.UUID
json.Unmarshal(ciphertext[userlib.BlockSize:], &g)
After decryption, the first few bytes are not correct and after unmarshalling, output is all zeros.