changed code for read write data and added some aes func