Digital data must be compressed and encrypted to maintain confidentiality and efficient bandwidth usage. These two parameters are essential for information processing in most communication systems. Image compression and encryption may result in reduced restoration quality and degraded performance. This study attempts to provide a compression and encryption scheme for digital data named as Secure-JPEG. This scheme is built on the JPEG compression format, the most widely used lossy compression scheme. It extends the standard JPEG compression algorithm to encrypt data during compression. Secure-JPEG scheme provides encryption along with the process of compression, and it could be altered easily to provide lossless compression. On the other hand, the lossless compression provides less compression ratio and is suitable only in specific scenarios. The paper address the problem of security lacks due to the use of a simple random number generator which can not be cryptographically secure. The improved security characteristics are provided through Generalized Bernoulli Shift Map, which has a chaotic system with demonstrated security. The algorithm's security is tested by several cryptographic tests and the chaotic system’s behavior is also analyzed.