diff --git a/MagickCore/cipher.c b/MagickCore/cipher.c
index 0c6daa4..5101425 100644
--- a/MagickCore/cipher.c
+++ b/MagickCore/cipher.c
@@ -337,7 +337,7 @@
   {
     value=ciphertext[i] ^ key[i];
     for (j=0; j < 4; j++)
-      *p++=(value >> (8*j)) & 0xff;
+      *p++=(unsigned char) ((value >> (8*j)) & 0xff);
   }
   /*
     Reset registers.