Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

After encryption of an image array using aes, when i try to save the encrypted image in jpg format using imwrite then the jpg image will have 0 bytes and type of the image becomes none

def encrypt_frames(arr,key_encrypt,iv_encrypt): cipher_text=np.array([])

  cipher = AES.new(key_encrypt, AES.MODE_CBC,iv_encrypt)
  cipher_text=cipher.encrypt(pad(arr,AES.block_size))
   return(cipher_text)

def main(): video_file='thumb0001.jpg' image=cv2.imread(video_file) print("Image Shape",image.shape) vid_arr_bytes=np.array([1,720,1280,3]) vid_arr_bytes=image.tobytes() key=get_random_bytes(16) iv=get_random_bytes(16) input_for_decrypt=encrypt_frames(vid_arr_bytes,key,iv) img=cv2.imwrite('frame0.jpg',img) if __name__=="__main__": main()

After encryption of an image array using aes, when i try to save the encrypted image in jpg format using imwrite then the jpg image will have 0 bytes and type of the image becomes none

Code:

def encrypt_frames(arr,key_encrypt,iv_encrypt):
      cipher_text=np.array([])

cipher_text=np.array([])
   cipher = AES.new(key_encrypt, AES.MODE_CBC,iv_encrypt)
   cipher_text=cipher.encrypt(pad(arr,AES.block_size))
    return(cipher_text)

def main(): video_file='thumb0001.jpg' image=cv2.imread(video_file) print("Image Shape",image.shape) vid_arr_bytes=np.array([1,720,1280,3]) vid_arr_bytes=image.tobytes() key=get_random_bytes(16) iv=get_random_bytes(16) input_for_decrypt=encrypt_frames(vid_arr_bytes,key,iv) img=cv2.imwrite('frame0.jpg',img) if __name__=="__main__": main()

main()

After encryption of an image array using aes, when i try to save the encrypted image in jpg format using imwrite then the jpg image will have 0 bytes and type of the image becomes none

Code:

def encrypt_frames(arr,key_encrypt,iv_encrypt):
      cipher_text=np.array([])

      cipher = AES.new(key_encrypt, AES.MODE_CBC,iv_encrypt)
      cipher_text=cipher.encrypt(pad(arr,AES.block_size))
       return(cipher_text)

def main():
     video_file='thumb0001.jpg'
     image=cv2.imread(video_file)
     print("Image Shape",image.shape)
     vid_arr_bytes=np.array([1,720,1280,3])
     vid_arr_bytes=image.tobytes()
     key=get_random_bytes(16)
     iv=get_random_bytes(16)
     input_for_decrypt=encrypt_frames(vid_arr_bytes,key,iv)
     img=cv2.imwrite('frame0.jpg',img)
if __name__=="__main__":
    main()

After encryption of an image array using aes, when i try to save the encrypted image in jpg format using imwrite then the jpg image will have 0 bytes and type of the image becomes none

Code:

def encrypt_frames(arr,key_encrypt,iv_encrypt):
      cipher_text=np.array([])

      cipher = AES.new(key_encrypt, AES.MODE_CBC,iv_encrypt)
      cipher_text=cipher.encrypt(pad(arr,AES.block_size))
       return(cipher_text)

def main():
     video_file='thumb0001.jpg'
     image=cv2.imread(video_file)
     print("Image Shape",image.shape)
     vid_arr_bytes=np.array([1,720,1280,3])
     vid_arr_bytes=image.tobytes()
     key=get_random_bytes(16)
     iv=get_random_bytes(16)
     input_for_decrypt=encrypt_frames(vid_arr_bytes,key,iv)
     img=cv2.imwrite('frame0.jpg',img)
img=np.frombuffer(input_for_decrypt,dtype=np.uint8)
     cv2.imwrite('frame0.jpg',img)
if __name__=="__main__":
    main()

After encryption of an image array using aes, when i try to save the encrypted image in jpg format using imwrite then the jpg image will have 0 bytes and type of the image becomes none

Code:

def encrypt_frames(arr,key_encrypt,iv_encrypt):
      cipher_text=np.array([])

      cipher = AES.new(key_encrypt, AES.MODE_CBC,iv_encrypt)
      cipher_text=cipher.encrypt(pad(arr,AES.block_size))
       return(cipher_text)

def main():
     video_file='thumb0001.jpg'
     image=cv2.imread(video_file)
     print("Image Shape",image.shape)
     vid_arr_bytes=np.array([1,720,1280,3])
     vid_arr_bytes=image.tobytes()
     key=get_random_bytes(16)
     iv=get_random_bytes(16)
     input_for_decrypt=encrypt_frames(vid_arr_bytes,key,iv)
     img=np.frombuffer(input_for_decrypt,dtype=np.uint8)
     cv2.imwrite('frame0.jpg',img)
if __name__=="__main__":
    main()

After encryption of an image array using aes, when i try to save the encrypted image in jpg format using imwrite then the jpg image will have 0 bytes and type of the image becomes none

Code:

def encrypt_frames(arr,key_encrypt,iv_encrypt):
      cipher_text=np.array([])

      cipher = AES.new(key_encrypt, AES.MODE_CBC,iv_encrypt)
      cipher_text=cipher.encrypt(pad(arr,AES.block_size))
       return(cipher_text)

def main():
     video_file='thumb0001.jpg'
     image=cv2.imread(video_file)
     print("Image Shape",image.shape)
     vid_arr_bytes=np.array([1,720,1280,3])
     vid_arr_bytes=image.tobytes()
     key=get_random_bytes(16)
     iv=get_random_bytes(16)
     input_for_decrypt=encrypt_frames(vid_arr_bytes,key,iv)
     img=np.frombuffer(input_for_decrypt,dtype=np.uint8)
     cv2.imwrite('frame0.jpg',img)
if __name__=="__main__":
    main()