The invention discloses a gun locking device based on a handgun and a gun locking and unlocking method. The problems that an existing gun lock is complex in structure, not high in reliability and inconvenient to use are solved. The gun locking device based on the handgun comprises a gun box for containing the handgun and a fixing plate for playing the separating effect, a gun box lock catch is arranged at the most front end of the portion, used for containing a gun barrel, of the gun box, an outer gun box located on the outer portion is arranged on one lateral face of the fixing plate, a locking mechanism located at the inner portion is arranged on the opposite lateral face, and the outer gun box is communicated with the locking mechanism. An opening is formed in the slantly-lower portion of the outer gun box, the gun box is inserted into the outer gun box from the opening, and the back end of the upper portion of the outer gun box is closed to be used for abutting against the back end of the portion, for containing the gun barrel, of the gun box. The gun box is inserted into the locking mechanism from the opening of the outer gun box, and the gun box lock catch is locked through the locking mechanism by rotating the gun box to achieve gun locking. The gun locking device is simple in structure, convenient to implement, safe and reliable.