Source: A simple pseudo-random number occurrence algorithm
//This code is purely for communication purposes, e.g. as a security area, at your own risk.#include<stdint.h>#include<stdlib.h>//! \brief Random seedStaticuint16_t S_hwrandomseed =0xaa55;Staticuint8_t s_chrandomtable[] = { 0x12,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF, 0xF1,0xe2,0xd3,0xc4,0xb5,0xa6,0x97,0x88};/*! \note set Random Generator seed * \param hwseed random seed* \return None*/voidset_random_seed (uint16_t hwseed) {s_hwrandomseed^=hwseed;}/*! \note get a random integer* \param none* \return random integer value*/uint16_t get_random_u16 (void) {uint16_t*phwresult = (uint16_t *) &s_chrandomtable[(S_hwrandomseed &0x0E)]; *phwresult + =S_hwrandomseed; S_hwrandomseed^= *Phwresult; return*Phwresult;}/*! \note get a random byte* \param none* \return random integer value*/uint8_t get_random_u8 (void ){ returnget_random_u16 ();}
/* The most commonly used random algorithm, C language standard library function results and this is consistent here is 32-bit machine, 8-bit machine add ul, change int to long */ int seed; void srand (int s) { = s;} int rand () { 226954771;}
A simple pseudo-random number occurrence algorithm (RPM)