Based on chaotic system and improved krill herb algorithm, so password flow is generated, and we put forward an effective medical image encryption method in this paper. The new method adopts adaptive function to sort krill individuals and select the best results. The output sequence of sub-key formed by location of part of individual encrypts medical image. Experimental results show that the new algorithm is more complexity and randomness than ordinary pseudo-random sequence generator. It limits the possibility of inferring all keys by attacker, and ensures the effectiveness of resistance in known plaintext attack. Finally, it achieves high security of encryption for medical images compared with other encryption methods.