A star tracker employs images of stars taken by a satellite-based camera to estimate its attitude and angular velocity in space. A star tracker is a flexible attitude sensor, which meets the requirements of a CubeSat. The objective of this paper is to develop an arc-minute accurate star tracker algorithm for CubeSats, and to analyze the results using a software-in-the-loop simulation. The algorithm is divided into three main parts: centroiding, Lost-in-Space (LIS) mode, and tracking mode. The weight sum method is used in centroiding, the voting method and quaternion-estimator (QUEST) method are used in the LIS mode, and the extended Kalman Filter (EKF) and catalog partitioning are used in tracking. Stars images are simulated to verify the algorithm. We evaluate centroid accuracy under different noise levels and star magnitudes, and the results have sub-pixel accuracy. In addition, we show the performance of LIS algorithm. With an appropriate voting tolerance, over 80% of the stars are correctly matched, the attitude estimations have arc-minute accuracy, and the matching results have over a 95% success rate. Also, the performance of the tracking algorithm is showed. The tracking results are successful, and the attitude estimation from the EKF has arc-minute accuracy.