Security and Cryptography
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsSystem AdministrationSecurity and Cryptography

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 6th, 2011, 02:38 PM
Karl-Uwe Frank Karl-Uwe Frank is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2011
Posts: 48 Karl-Uwe Frank User rank is Second Lieutenant (5000 - 10000 Reputation Level)Karl-Uwe Frank User rank is Second Lieutenant (5000 - 10000 Reputation Level)Karl-Uwe Frank User rank is Second Lieutenant (5000 - 10000 Reputation Level)Karl-Uwe Frank User rank is Second Lieutenant (5000 - 10000 Reputation Level)Karl-Uwe Frank User rank is Second Lieutenant (5000 - 10000 Reputation Level)Karl-Uwe Frank User rank is Second Lieutenant (5000 - 10000 Reputation Level)Karl-Uwe Frank User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 11 h 19 m 38 sec
Reputation Power: 54
SqRNG32 - "Spin the Wheel Slot Machine"

This is just another new Pseudo Random Number Generator based on pqRNG and it's a slightly Modification of xqRNG32.

*** Currently not undergone any statistical Test ***


The Idea behind is "porting" a mechanical Spinning Wheel Slot Machine into a simple and fast Computer based Algorithm. Please imagine a big Wheel containing 32 smaller Wheels where each of it has 256 Slots filled with numbered Gold Coins.

The functionality of the imaginary mechanical "Spin the Wheel Slot Machine" would be as follows:

#) Each Slot will be filled with 2^32 Gold Coins in a randomly Fashion.

#) A HEX-Number from 0x00 up to 0xFF is embossed on both Sides of each Coins.

#) Now we start spinning the big Wheel until it comes to hold.

#) Next we spin the small Wheel in Front of us until it comes to hold as well.

#) We draw one Gold Coin from the Slot in Front and place it on a Tray.

#) After another 3 Times repeating this Procedure we have 4 Coins with HEX-Numbers on the Tray.

#) These concatenated 4 HEX-Numbers build the 32-bit Random Value as the Result.



The C++ Listing of the imaginary "Spin the Wheel Slot Machine" will read as follows:

Code:
/* sqRNG32, Pseudo Random Number Generator based on pqRNG */
/* written by Karl-Uwe Frank, Copyright (c) 2011 Adverteam Limited (UK) */

/*
 Free to use with or without modification and without a fee is granted
 only for private, research, academic or other non-commercial purposes.
 http://www.adverteam.co.uk/sqRNG32/LICENCE
*/

static unsigned int seed;
static unsigned int Q, P, R;
static unsigned int X[32];
static unsigned int aP[32][256], aR[32][256];

void sqRNG32_Init() {
  Q  = seed;
  P  = 0x11B923B;
  R  = 0x6FC55;
	
  unsigned int tQ, tP, tR;
  int i, k;

  for (i=0; i<32; i++) {
    Q = ((Q ^ R) * P);	
    tP = Q;
    while ((tP & 0x7) != 3) tP++;
    tR = (tP >> 3);
    while ((tR & 0x7) != 5) tR++;

    X[i] = Q ^ seed;
    tQ = X[i];

    for (k=0; k<256; k++) {
      tQ = ((tQ ^ tR) * tP);
      aP[i][k] = tQ;
      while ((aP[i][k] & 0x7) != 3) aP[i][k]++;
      aR[i][k] = (aP[i][k] >> 3);
      while ((aR[i][k] & 0x7) != 5) aR[i][k]++;
    }
  }
}


unsigned int sqRNG32() {
  unsigned int Wheel;
  unsigned int Slot;
  unsigned char ByteX[4];
  int i;
	
  for (i=0; i<4; i++) {
    Q = ((Q ^ R) * P);
    Wheel = Q >> 27;
    Q = ((Q ^ R) * P);
    Slot = Q >> 24;
    X[Wheel] = (X[Wheel] ^ aR[Wheel][Slot]) * aP[Wheel][Slot];
    ByteX[i] = X[Wheel] >> 24;
  }
	
  return (ByteX[0] << 24 | ByteX[1] << 16 | ByteX[2] << 8 | ByteX[3]);
}


Annotation: This PRNG should not be considered cryptographically secure.

Further Information and a documented C++ Source Code of sqRNG32 can be found at http://www.adverteam.co.uk/sqRNG32/

Cheers,
Karl-Uwe

---
Copyright (c) 2011 Adverteam Limited (UK), Karl-Uwe Frank
All rights reserved.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationSecurity and Cryptography > SqRNG32 - "Spin the Wheel Slot Machine"

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap