2006 Copyright Filed by IT GlobalSecure, Inc. All Rights Reserved. Not to be used without authorization by Author. SecurePlay, IT GlobalSecure, and IT Armor are registered trademarks by IT GlobalSecure, Inc. Software protected by software license, and one or more the following U.S. and International patent numbers: U.S. Patent 6,030,288, U.S. Patent 6,165,072, European Patent Office EP1016049A1,and World Intellectual Property Organization WO9912135C1 and additional filings worldwide.
Main Page | Class Hierarchy | Class List | Class Members

SecurePlayLibrary::SPUtil Class Reference

#include <SPUtil.h>

List of all members.

Static Public Member Functions

string rippleadd1 (string inputstring)
string char62circadd (string str1, string str2)
string char62circsub (string str1, string str2)
int char62code2num (char c)
int num2char62code (int x)
int SPsmoothValue (int sampleSize, int seed, vector< int > keyArray)
string INTdelimiter ()
string MESSdelimiter ()
string INTMESSdelimiter ()
string stringArrTostring (vector< string > sa, string delim)
vector< string > stringArrAddEl (vector< string > sa, string str)
vector< int > IntArrAddEl (vector< int > iarr, int i)
vector< int > arrSplice (vector< int > iarr, int pos)
vector< string > stringArrAddArr (vector< string > sa1, vector< string > sa2)
vector< string > ByteArrTostringArr (vector< SPbyte > bt)
vector< SPbyte > stringArrToByteArr (vector< string > strarr)
vector< string > stringTostringArr (string str, string del)
int toInt (const char *str)
string tostring (int i)
vector< string > stringArrRemoveEl (vector< string > sa, string str)
string BinaryTostring (vector< SPbyte > digest)
vector< SPbyte > stringToBinary (string str)
int stringToInt (const char *str)
int HexstringToInt (const string hexStrIN)
string IntTostring (int i)
string IntTostring (int i, int hexdec)
vector< SPbyte > ByteArrAddArr (vector< SPbyte > sa1, vector< SPbyte > sa2)
vector< SPbyte > ByteArrAddEl (vector< SPbyte > sa, SPbyte str)
vector< SPbyte > IntToByte (int i)
vector< SPbyte > subByteArr (vector< SPbyte > inbArr, int start, int end)
bool arrComp (vector< SPbyte > b1, vector< SPbyte > b2)
vector< string > stringArrGETsubArr (vector< string > strArr, int indexStart, int indexEnd)
vector< SPbyte > ByteArrGETsubArr (vector< SPbyte > strArr, int indexStart, int indexEnd)
string LongTostring (long i)
long stringToLong (string str)
bool comparestringArrays (vector< string > str1, vector< string > str2)
bool registerTransaction (string transName, SPAbstractTransactionInterface *transInstance)
vector< string > viewRegisteredTransaction ()
SPAbstractTransactionInterfacegetRegisteredTransaction (string key)
string SPgenerateKey (int keySize)
string SPtransform (string input, string gameid)
vector< SPbyte > getHashText (string plainText, string algorithm)
bool isElementIncluded (string elem, vector< string > array)
bool stringArrContainsEl (vector< string > arr, string elem)
int XreferenceTwoArrays (vector< string > arr1, vector< string > arr2)
bool IsArrayIntersectionTrue (vector< string > arr1, vector< string > arr2)
vector< string > ArrayIntersection (vector< string > arr1, vector< string > arr2)
long getTime ()
int getNextRandom ()

Static Public Attributes

const string INTERNAL_COMMS = "internal"
const int SP_ID_SIZE = 12
const int SP_KEY_SIZE = 25
const int SP_UPDATE_INTERVAL = 380
string SP_TESTSEGMENT = "THISISANONCOMMERCIALONLYSECUREPLAYLICENSEAAAAAAAAAA"
const string intDel = ":"
const string messDel = ";"
const string interMessDell = "~"


Detailed Description

These are global functions and constants that can be used by various portions of the SecurePlay library. Some methods in this class wrap functions to accomodate between J2me and J2se. NOTE: Some may be simply placeholders for application specific services such as the hash, encryption, and signature functions.
Author:
IT GlobalSecure
See also:
SecurePlay License Information


Member Function Documentation

vector< string > SPUtil::ArrayIntersection vector< string >  arr1,
vector< string >  arr2
[static]
 

Cross References two string array and returns the common strings or mathces occured between two arrays.

Parameters:
arr1 string[] - array one
arr2 string[] - array two
Returns:
int

bool SPUtil::arrComp vector< SPbyte >  b1,
vector< SPbyte >  b2
[static]
 

This method compares two byte arrays.

Parameters:
b1 byte[] - byte array to be compared
b2 byte[] - byte array to be compared
Returns:
boolean Boolean: TRUE, if the game was created successfully, FALSE, otherwise

vector< int > SPUtil::arrSplice vector< int >  iarr,
int  pos
[static]
 

Returns a new array that removes a single element from the input Integer array at a given position

Parameters:
iarr Integer[] - the Integer array to be edited.
pos int - the position from where the element is to be removed.
Returns:
intArr - Integer[] - the Integer array that has the specified element removed.

string SPUtil::BinaryTostring vector< SPbyte >  digest  )  [static]
 

This method convets a byte array to a string where each byte is split into two characters providing the hex representation of the byte.

Parameters:
digest byte[] - byte array to be converted
Returns:
string - the converted string.

vector< SPbyte > SPUtil::ByteArrAddArr vector< SPbyte >  sa1,
vector< SPbyte >  sa2
[static]
 

This method add two byte arrays together.

Parameters:
sa1 byte[] - byte array to be added.
sa2 byte[] - byte array to be added.
Returns:
sa - byte[] - added byte array.

vector< SPbyte > SPUtil::ByteArrAddEl vector< SPbyte >  sa,
SPbyte  str
[static]
 

This function appends a byte element to the end of the byte array.

Parameters:
sa byte[] - a byte array that needs an element to be added.
str byte - the element to be added.
Returns:
strArr[] - byte[] - the byte array with added element

vector< SPbyte > SPUtil::ByteArrGETsubArr vector< SPbyte >  strArr,
int  indexStart,
int  indexEnd
[static]
 

This method gets the sub array of a Stirng array.

Parameters:
strArr string[] - the array from which the sub array will be extracted
indexStart int - starting index.
indexEnd int - ending index.
Returns:
string[] - the sub array.

vector< string > SPUtil::ByteArrTostringArr vector< SPbyte >  bt  )  [static]
 

Converts byte array into string array.

Parameters:
bt byte[] - byte array to be converted.
Returns:
string[]

string SPUtil::char62circadd string  str1,
string  str2
[static]
 

This function does a circular, character by character addition mod 62 assuming the strings are "right justified". This returns the result as a new string.

Parameters:
str1 string
str2 string
Returns:
resultstring - string:

string SPUtil::char62circsub string  str1,
string  str2
[static]
 

This function does a circular, character by character subtraction mod 62 assuming the strings are "right justified" this returns the result as a new string.

Parameters:
str1 string
str2 string
Returns:
resultstring - string

int SPUtil::char62code2num char  c  )  [static]
 

This function takes the character code provided and converts it to a number between 0 and 61

Parameters:
c char - a character code
Returns:
x - int - a number between 0 and 61

bool SPUtil::comparestringArrays vector< string >  str1,
vector< string >  str2
[static]
 

Compares two string arrays if they contain identical items. The order does not matter, just as long as they contain number and same strings.

Parameters:
str1 
str2 
Returns:
boolean

vector< SPbyte > SPUtil::getHashText string  plainText,
string  algorithm
[static]
 

This method gets the hashed string

Parameters:
plainText string - string to be hashed
algorithm string - The algorithm to use like MD2, MD5, SHA-1, etc.
Returns:
hash - string - the hashed string

int SPUtil::getNextRandom  )  [static]
 

SPAbstractTransactionInterface * SPUtil::getRegisteredTransaction string  key  )  [static]
 

This method gets a registered Transaction object from the register list and returns it to the user.

Parameters:
key string - the name of the transaction.
Returns:
SPAbstractTransactionInterface

long SPUtil::getTime  )  [static]
 

int SPUtil::HexstringToInt const string  hexStrIN  )  [static]
 

vector< int > SPUtil::IntArrAddEl vector< int >  iarr,
int  i
[static]
 

This function appends a integer element to the end of the integer array.

Parameters:
iarr Integer[] - the integer array that needs an element to be added.
i int - the element to be added.
Returns:
intArr - Integer[] - the Integer array with the added element.

string SPUtil::INTdelimiter  )  [static]
 

Returns a string delimiter1 Delimiter1 = ":" Used for serializing internal message arrays

Returns:
del - string

string SPUtil::INTMESSdelimiter  )  [static]
 

Returns a string delimiter3 Delimiter3 = "~" Used for serialising multiple messages

Returns:
string

vector< SPbyte > SPUtil::IntToByte int  i  )  [static]
 

This method converts an integer into a byte array.

Parameters:
i int - integer to be converted
Returns:
intB - byte[] - integer that has been converted to byte.

string SPUtil::IntTostring int  i,
int  hexdec
[static]
 

Integer to string.

Parameters:
i int - int number to be converted to string
Returns:
str - string - string representation of the integer number

string SPUtil::IntTostring int  i  )  [static]
 

Integer to string.

Parameters:
i int - int number to be converted to string
Returns:
str - string - string representation of the integer number

bool SPUtil::IsArrayIntersectionTrue vector< string >  arr1,
vector< string >  arr2
[static]
 

Cross References two string array and returns number of same strings or mathces occured between two arrays.

Parameters:
arr1 string[] - array one
arr2 string[] - array two
Returns:
int

bool SPUtil::isElementIncluded string  elem,
vector< string >  array
[static]
 

This method checks to see if an element is included in a string array.

Parameters:
elem string - element to be checked.
array string[] - string array to be checked.
Returns:
boolean - TRUE: if element exists in the array, FALSE: if the element does not exist in the array.

string SPUtil::LongTostring long  i  )  [static]
 

Long to string.

Parameters:
i int - int number to be converted to string
Returns:
str - string - string representation of the integer number

string SPUtil::MESSdelimiter  )  [static]
 

Returns a string delmiter2 Delimiter2 = ";" Used for serializing the message

Returns:
del2 - string

int SPUtil::num2char62code int  x  )  [static]
 

this function takes a numerical value between 0 and 61 and converts it to a character code from 0..9A..Za..z

Parameters:
x int - a number between 0 and 61
Returns:
c - int - a character code

bool SPUtil::registerTransaction string  transName,
SPAbstractTransactionInterface transInstance
[static]
 

This method registers Transaction objects with so that they can be used in this library.

Parameters:
transName string - transaction name
transInstance SPAbstractTransactionInterface - the transaction object instance
Returns:
boolean

string SPUtil::rippleadd1 string  inputstring  )  [static]
 

This function adds 1 to the low order character of a string. It returns the result as a returned string value the input string is from the range - 0..9A..Za..z.

Parameters:
inputstring string
Returns:
resultstring - string

string SPUtil::SPgenerateKey int  keySize  )  [static]
 

This function generates a "real" random key that is easily stored in a printable string. THIS FUNCTION SHOULD NOT BE USED FOR PRODUCTION GAMES. PLEASE USE A REAL RANDOM TOOL. THIS FUNCTION IS PROVIDED AS A SAMPLE ONLY

Parameters:
keySize int - a positive value - should be large enough to generate a good range of keys. SecurePlay library examples use 25
Returns:
generatedkey - string - a base 62 0..9A..Za..z string

int SPUtil::SPsmoothValue int  sampleSize,
int  seed,
vector< int >  keyArray
[static]
 

This is a somewhat smooth, keyed, pseudorandom number generator. It generates a result between 0 and SampleSize -1. It uses the seed to generate a range of possible outcomes and it is driven by an array keyArray. THIS FUNCTION SHOULD NOT BE USED FOR PRODUCTION GAMES. CAREFUL SELECTION OF PSEUDO-RANDOM NUMBER GENERATORS IS CRITICAL.

Parameters:
sampleSize int
seed int
keyArray Integer[]
Returns:
Positive - int - pseudorandom number.

string SPUtil::SPtransform string  input,
string  gameid
[static]
 

This function performs an irreversible transform on an input string to generate an output string. The sample implementation uses MD5. This method can be overridden and should be reviewed for security purposes prior to use in a production implementation.

Parameters:
input string
Returns:
str - string

vector< string > SPUtil::stringArrAddArr vector< string >  sa1,
vector< string >  sa2
[static]
 

This method add two string arrays together.

Parameters:
sa1 string[] - string array to be added.
sa2 string[] - string array to be added.
Returns:
sa - string[] - added string array.

vector< string > SPUtil::stringArrAddEl vector< string >  sa,
string  str
[static]
 

This function appends a string element to the end of the string array.

Parameters:
sa string[] - a string array that needs an element to be added.
str string - the element to be added.
Returns:
strArr[] - string[] - the string array with added element

bool SPUtil::stringArrContainsEl vector< string >  arr,
string  elem
[static]
 

Checks to see if the array contains the specified element.

Parameters:
arr 
elem 
Returns:
boolean

vector< string > SPUtil::stringArrGETsubArr vector< string >  strArr,
int  indexStart,
int  indexEnd
[static]
 

This method gets the sub array of a Stirng array.

Parameters:
strArr string[] - the array from which the sub array will be extracted
indexStart int - starting index.
indexEnd int - ending index.
Returns:
string[] - the sub array.

vector< string > SPUtil::stringArrRemoveEl vector< string >  sa,
string  str
[static]
 

This function removes a string element from a string array.

Parameters:
sa string[] - a string array that needs an element to be removed.
str string - the element to be removed.
Returns:
strArr[] - string[] - the string array with removed element, IF the element did not exist then it returns the original string array.

vector< SPbyte > SPUtil::stringArrToByteArr vector< string >  strarr  )  [static]
 

This method converts a string array to a byte array.

Parameters:
strarr string[] - string array
Returns:
byte[]

string SPUtil::stringArrTostring vector< string >  sa,
string  delim
[static]
 

Parces the string array into a string with delimiters separating each array indexes

Parameters:
sa string[] - string array to be converted into a string
delim string - the delimiter that will parce the string
Returns:
str - string

vector< SPbyte > SPUtil::stringToBinary string  str  )  [static]
 

string to binary

Parameters:
str 
Returns:
byte[]

int SPUtil::stringToInt const char *  str  )  [static]
 

string to integer.

Parameters:
str string - string number to be converted to int.
Returns:
i - int - int type number converted from string.

long SPUtil::stringToLong string  str  )  [static]
 

string to Long.

Parameters:
str string - string number to be converted to long
Returns:
l - long - long representation of the string number

vector< string > SPUtil::stringTostringArr string  str,
string  del
[static]
 

This method converts a string to a string array using the specified delimiter.

Parameters:
str string - string to be converted.
del string - the delimiter to be used to parce the string.
Returns:
string[]

vector< SPbyte > SPUtil::subByteArr vector< SPbyte >  inbArr,
int  start,
int  end
[static]
 

This method retrieves the specified sub array of a byte array passed in.

Parameters:
inbArr byte[] - byte array to be subed from.
start int - start index of the sub array.
end int - end index of the sub array.
Returns:
subArr - byte[] - the sub array.

int SPUtil::toInt const char *  str  )  [static]
 

Converts a string representaion of an integer to Integer class.

Parameters:
str - string - string representaion of an integer
Returns:
integer - Integer

string SPUtil::tostring int  i  )  [static]
 

Converts an integer to string.

Parameters:
i - int
Returns:
str - string

vector< string > SPUtil::viewRegisteredTransaction  )  [static]
 

This method allows users to see what transactions have been registered.

Returns:
string[]

int SPUtil::XreferenceTwoArrays vector< string >  arr1,
vector< string >  arr2
[static]
 

Cross References two string array and returns number of same strings or mathces occured between two arrays.

Parameters:
arr1 string[] - array one
arr2 string[] - array two
Returns:
int


Member Data Documentation

const string SPUtil::intDel = ":" [static]
 

Delimiter1 = : Used for serializing internal message arrays

const string SPUtil::interMessDell = "~" [static]
 

Delimeter3 = ~ Used for serializing multiple messages

const string SPUtil::INTERNAL_COMMS = "internal" [static]
 

Comms internal

const string SPUtil::messDel = ";" [static]
 

Delimiter2 = ; Used for serializing the message

const int SPUtil::SP_ID_SIZE = 12 [static]
 

This value is used to set the default size of generated IDs - default is 12

const int SPUtil::SP_KEY_SIZE = 25 [static]
 

This value is used to set game key size. Default is 25.

string SPUtil::SP_TESTSEGMENT = "THISISANONCOMMERCIALONLYSECUREPLAYLICENSEAAAAAAAAAA" [static]
 

This Constant is used to generate a Game Segment ID for sample code.

const int SPUtil::SP_UPDATE_INTERVAL = 380 [static]
 

This parameter is used to force an update check - only necessary for polling communications. Default is 3800.


The documentation for this class was generated from the following files: 2006 Copyright Filed by IT GlobalSecure, Inc. All Rights Reserved. Not to be used without authorization by Author. SecurePlay, IT GlobalSecure, and IT Armor are registered trademarks by IT GlobalSecure, Inc. Software protected by software license, and one or more the following U.S. and International patent numbers: U.S. Patent 6,030,288, U.S. Patent 6,165,072, European Patent Office EP1016049A1,and World Intellectual Property Organization WO9912135C1 and additional filings worldwide.