A method performed by a second device in a wireless communication system, the method comprising: receiving, from a first device, data encrypted using a previous encryption key generated based on a previous sweeping order, of the second device, associated with a previous measurement result for a plurality of previous reference signals of the first device; determining a sweeping order of a plurality of receive beams, of the second device, for a beam sweeping, wherein the sweeping order of the plurality of receive beams of the second device is different from the previous sweeping order of the second device; performing the beam sweeping of the plurality of receive beams by using the sweeping order of the plurality of receive beams of the second device, receiving, from the first device, a plurality of reference signals of the first device based on a plurality of transmission beams of the first device and the beam sweeping of the plurality of receive beams of the second device; generating a decryption key based on a first measurement result, the sweeping order of the plurality of receive beams of the second device, and a resource difference between a first resource of a first beam pair and a second resource of a second beam pair, the first measurement result including first information indicating at least one reference signal of the first device among the plurality of reference signals of the first device and second information indicating the sweeping order of the plurality of receive beams of the second device; transmitting, to the first device, a plurality of reference signals of the second device based on a sweeping order of a plurality of transmission beams of the second device, the sweeping order of the plurality of transmission beams of the second device corresponding to the sweeping order of the plurality of receive beams of the second device; and receiving, from the first device, data encrypted using an encryption key generated based on the plurality of reference signals of the second device, a sweeping order of a plurality of receive beams of the first device, and the resource difference between the first resource of the first beam pair and the second resource of the second beam pair, the encryption key corresponding to the decryption key, wherein a plurality of beam pairs provide a receive strength greater than a threshold, the plurality of beam pairs including combinations of the plurality of transmission beams of the first device and the plurality of receive beams of the second device, and wherein the first beam pair is one of the plurality of beam pairs and the second beam pair, different from the first beam pair, is one of the plurality of beam pairs. receiving, from a first device, data encrypted using a previous encryption key generated based on a previous sweeping order, of the second device, associated with a previous measurement result for a plurality of previous reference signals of the first device; determining a sweeping order of a plurality of receive beams, of the second device, for a beam sweeping, wherein the sweeping order of the plurality of receive beams of the second device is different from the previous sweeping order of the second device; performing the beam sweeping of the plurality of receive beams by using the sweeping order of the plurality of receive beams of the second device, receiving, from the first device, a plurality of reference signals of the first device based on a plurality of transmission beams of the first device and the beam sweeping of the plurality of receive beams of the second device; generating a decryption key based on a first measurement result, the sweeping order of the plurality of receive beams of the second device, and a resource difference between a first resource of a first beam pair and a second resource of a second beam pair, the first measurement result including first information indicating at least one reference signal of the first device among the plurality of reference signals of the first device and second information indicating the sweeping order of the plurality of receive beams of the second device; transmitting, to the first device, a plurality of reference signals of the second device based on a sweeping order of a plurality of transmission beams of the second device, the sweeping order of the plurality of transmission beams of the second device corresponding to the sweeping order of the plurality of receive beams of the second device; and receiving, from the first device, data encrypted using an encryption key generated based on the plurality of reference signals of the second device, a sweeping order of a plurality of receive beams of the first device, and the resource difference between the first resource of the first beam pair and the second resource of the second beam pair, the encryption key corresponding to the decryption key, wherein a plurality of beam pairs provide a receive strength greater than a threshold, the plurality of beam pairs including combinations of the plurality of transmission beams of the first device and the plurality of receive beams of the second device, and wherein the first beam pair is one of the plurality of beam pairs and the second beam pair, different from the first beam pair, is one of the plurality of beam pairs.