With the increasing computational capability of computer, the security of data transmission in computer network has been threatened. To meet the requirement of computational security, traditional cryptosystems have to keep lengthening the key-size. By applying the data hiding, one of the applications of data hiding, is a technique to hide the encrypted data, called secret, into a cover image to avoid passive cryptanalysis. The challenge of this kind of technique is how to hide as much secret as possible in the cover image while the embedded image, called stego-image, is visually acceptable. In this paper, we propose an a-LSB based secret hiding method, called dynamic n-LSB, is used to improve the quality of stego-images. An important transformation function has derived from the Gaussian noise model. It provides a theoretical method to obtain the optimum value of n that leads to a better quality of stego-images for the dynamic n-LSB method. With the transformation function, the capacity of secret hiding is also concluded.