Happy women girl female gliding climbing in extreme road trolley zipline in forest on carabiner safety link on tree to tree top rope adventure park. Family weekend children kids activities concept

Code to create quantum encryption and entanglement

Start
//This code sample demonstrates how to generate quantum encryption and entanglement using Q# and the Qiskit library.

namespace QuantumEncryption 
{
    open Microsoft.Quantum.Intrinsic;
    open Microsoft.Quantum.Canon;
    open Microsoft.Quantum.Math;

    operation GenerateQuantumEncryption () : ((Qubit[],Qubit[]) is Adj+Ctl)
    {
        using (qubitsA = Qubit[2],qubitsB = Qubit[2])
        {
            // Apply the Bell state to the qubits
            Bell(qubitsA[0], qubitsB[0]);
            Bell(qubitsA[1], qubitsB[1]);

            // Apply a Hadamard to each qubit in the first register
            for (i in 0..1) 
            {
                H(qubitsA[i]);
            }

            // Apply a CNOT to each qubit in the second register
            for (i in 0..1) 
            {
                CNOT(qubitsB[i],qubitsA[i]);
            }

            // Measure the entangled qubits
            let measA = MResetZ(qubitsA);
            let measB = MResetZ(qubitsB);

            // Create the encrypted key
            let key = (measA,measB);

            // Return the encrypted key
            return key;
        }
    }
}
Previous Story

RCCI Exam Prep Guide

Next Story

S3 Ep119: Breaches, patches, leaks and tweaks! [Audio + Text]