Low power wide area networks (LPWANs) enable large-scale deployments of low-power wireless devices. LoRaWAN is a long-range wireless technology that has emerged as a low-power and low-data rate solution to support Internet-of-Things applications. Although LoRaWAN provides a low-power and cost-efficient networking solution, recent literature shows that it performs poorly in terms of reliability and security in dense deployments due to the uncoordinated (ALOHA-based) nature of the MAC protocol. Furthermore, LoRaWAN is not robust against selective jamming attacks. This paper proposes CRAM: a time-synchronized cryptographic frequency hopping MAC protocol designed for the LoRa physical layer. CRAM reduces the contention by fairly exploiting the available frequency space and maximises the entropy of the channel hopping algorithm. We develop a large physical test-bed and a simulator to thoroughly evaluate the proposed protocol. Our evaluations show that CRAM significantly improves reliability and scalability and increases channel utilization while making selective jamming difficult to perform compared to the standard LoRaWAN protocol.