Public Function genNumber(appName)
Dim appVal As Long
Dim genVal As Long
Dim tmpVar As String
Dim i As Integer
Dim seedMod As Integer
Dim temp As Integer
Dim lastGroup As String
For i = 1 To Len(appName) - 0
appVal = appVal + Val(Asc(Mid$(appName, i, 1))) ' <<< Counts the value of each ascii chr
Next ' in the app name'TODO: modify the algorithm for the seeding to be more random
seedMod = Int((Day(Date) & Month(Date) & Year(Date) & Hour(Time) & Minute(Time) & Second(Time)) ^ 0.2)temp = seedMod + (Minute(Time) & Second(Time))
For i = 0 To temp ' <<< Vb's random num generator is not
Rnd ' very random so i will make it more
Next ' randomtmpVar = ""
For i = 1 To 20 ' <<< Randomly create the 1st 4 parts of the code
If (Rnd < 0.65 Or i = 1) And i <> 13 Then ' <<< 1 in two chance of a letter or a number
tmpVar = tmpVar & Chr(Int(Rnd * 25) + 65)
Else
tmpVar = tmpVar & Int(Rnd * 9)
End If
If Int(i / 5) = i / 5 And i <> 25 Then ' <<< Add a ' - ' every 5 charachters
tmpVar = tmpVar & " - "
End If
NextFor i = 1 To Len(tmpVar) - 0 ' <<< Creates a number based on the
If i < Len(appName) Then ' first sections. Adds or takes
If getPlusMinus(Mid(appName, i, 1)) = False Then ' depending on various things
genVal = genVal + Val(Asc(Mid$(tmpVar, i, 1))) ' Makes it mathematicaly harder
Else ' to re-order the code.
genVal = genVal - Val(Asc(Mid$(tmpVar, i, 1)))
End If
Else
If Int(i / 2) = i / 2 Then
genVal = genVal - Val(Asc(Mid$(tmpVar, i, 1)))
Else
genVal = genVal + Val(Asc(Mid$(tmpVar, i, 1)))
End If
End If
Next
If genVal < 0 Then genVal = 0 - genVal ' <<< If the number is less than 0 then make it
' positivetmpVar = tmpVar & Mid((genVal * appVal) & "TKYEH", 1, 5) ' <<< Last part of the code is the
' 'value' of the first part of
' the code times the 'value'
' of the program name, limited
' to 5 charachters. "JSDEU" is
' to make sure the result is
' atleast 5 chars.
genNumber = UCase(tmpVar) ' <<< Returns the new key
End Function
Dim appVal As Long
Dim genVal As Long
Dim tmpVar As String
Dim i As Integer
Dim seedMod As Integer
Dim temp As Integer
Dim lastGroup As String
For i = 1 To Len(appName) - 0
appVal = appVal + Val(Asc(Mid$(appName, i, 1))) ' <<< Counts the value of each ascii chr
Next ' in the app name'TODO: modify the algorithm for the seeding to be more random
seedMod = Int((Day(Date) & Month(Date) & Year(Date) & Hour(Time) & Minute(Time) & Second(Time)) ^ 0.2)temp = seedMod + (Minute(Time) & Second(Time))
For i = 0 To temp ' <<< Vb's random num generator is not
Rnd ' very random so i will make it more
Next ' randomtmpVar = ""
For i = 1 To 20 ' <<< Randomly create the 1st 4 parts of the code
If (Rnd < 0.65 Or i = 1) And i <> 13 Then ' <<< 1 in two chance of a letter or a number
tmpVar = tmpVar & Chr(Int(Rnd * 25) + 65)
Else
tmpVar = tmpVar & Int(Rnd * 9)
End If
If Int(i / 5) = i / 5 And i <> 25 Then ' <<< Add a ' - ' every 5 charachters
tmpVar = tmpVar & " - "
End If
NextFor i = 1 To Len(tmpVar) - 0 ' <<< Creates a number based on the
If i < Len(appName) Then ' first sections. Adds or takes
If getPlusMinus(Mid(appName, i, 1)) = False Then ' depending on various things
genVal = genVal + Val(Asc(Mid$(tmpVar, i, 1))) ' Makes it mathematicaly harder
Else ' to re-order the code.
genVal = genVal - Val(Asc(Mid$(tmpVar, i, 1)))
End If
Else
If Int(i / 2) = i / 2 Then
genVal = genVal - Val(Asc(Mid$(tmpVar, i, 1)))
Else
genVal = genVal + Val(Asc(Mid$(tmpVar, i, 1)))
End If
End If
Next
If genVal < 0 Then genVal = 0 - genVal ' <<< If the number is less than 0 then make it
' positivetmpVar = tmpVar & Mid((genVal * appVal) & "TKYEH", 1, 5) ' <<< Last part of the code is the
' 'value' of the first part of
' the code times the 'value'
' of the program name, limited
' to 5 charachters. "JSDEU" is
' to make sure the result is
' atleast 5 chars.
genNumber = UCase(tmpVar) ' <<< Returns the new key
End Function
public object genNumber(System.Object appName)
{
long appVal = 0;
long genVal = 0;
string tmpVar = null;
int i = 0;
int seedMod = 0;
int temp = 0;
string lastGroup = null;
for (i = 1; i <= Strings.Len(appName) - 0; i++) {
// < < < Counts the value of each ascii chr
appVal = appVal + Conversion.Val(Strings.Asc(Strings.Mid(appName, i, 1)));
}
// in the app name
//TODO: modify the algorithm for the seeding to be more random
seedMod = Conversion.Int(Math.Pow((Day(System.DateTime) + Month(System.DateTime) + Year(System.DateTime) + Hour(Time) + Minute(Time) + Second(Time)), 0.2));
temp = seedMod + (Minute(Time) + Second(Time));
for (i = 0; i <= temp; i++) {
// < < < Vb's random num generator is not
// very random so i will make it more
VBMath.Rnd();
}
// random
tmpVar = "";
for (i = 1; i <= 20; i++) {
// < < < Randomly create the 1st 4 parts of the code
if ((Rnd < 0.65 | i == 1) & i != 13) {
// < < < 1 in two chance of a letter or a number
tmpVar = tmpVar + Strings.Chr(Conversion.Int(Rnd * 25) + 65);
}
else {
tmpVar = tmpVar + Conversion.Int(Rnd * 9);
}
if (Conversion.Int(i / 5) == i / 5 & i != 25) {
// < < < Add a ' - ' every 5 charachters
tmpVar = tmpVar + " - ";
}
}
for (i = 1; i <= Strings.Len(tmpVar) - 0; i++) {
// < < < Creates a number based on the
if (i < Strings.Len(appName)) {
// first sections. Adds or takes
if (getPlusMinus(Strings.Mid(appName, i, 1)) == false) {
// depending on various things
// Makes it mathematicaly harder
genVal = genVal + Conversion.Val(Strings.Asc(Strings.Mid(tmpVar, i, 1)));
}
else {
// to re-order the code.
genVal = genVal - Conversion.Val(Strings.Asc(Strings.Mid(tmpVar, i, 1)));
}
}
else {
if (Conversion.Int(i / 2) == i / 2) {
genVal = genVal - Conversion.Val(Strings.Asc(Strings.Mid(tmpVar, i, 1)));
}
else {
genVal = genVal + Conversion.Val(Strings.Asc(Strings.Mid(tmpVar, i, 1)));
}
}
}
if (genVal < 0) genVal = 0 - genVal;
// < < < If the number is less than 0 then make it
// positive
tmpVar = tmpVar + Strings.Mid((genVal * appVal) + "TKYEH", 1, 5);
// < < < Last part of the code is the
// 'value' of the first part of
// the code times the 'value'
// of the program name, limited
// to 5 charachters. "JSDEU" is
// to make sure the result is
// atleast 5 chars.
// < < < Returns the new key
return Strings.UCase(tmpVar);
}
{
long appVal = 0;
long genVal = 0;
string tmpVar = null;
int i = 0;
int seedMod = 0;
int temp = 0;
string lastGroup = null;
for (i = 1; i <= Strings.Len(appName) - 0; i++) {
appVal = appVal + Conversion.Val(Strings.Asc(Strings.Mid(appName, i, 1)));
}
seedMod = Conversion.Int(Math.Pow((Day(System.DateTime) + Month(System.DateTime) + Year(System.DateTime) + Hour(Time) + Minute(Time) + Second(Time)), 0.2));
temp = seedMod + (Minute(Time) + Second(Time));
for (i = 0; i <= temp; i++) {
VBMath.Rnd();
}
tmpVar = "";
for (i = 1; i <= 20; i++) {
if ((Rnd < 0.65 | i == 1) & i != 13) {
tmpVar = tmpVar + Strings.Chr(Conversion.Int(Rnd * 25) + 65);
}
else {
tmpVar = tmpVar + Conversion.Int(Rnd * 9);
}
if (Conversion.Int(i / 5) == i / 5 & i != 25) {
tmpVar = tmpVar + " - ";
}
}
for (i = 1; i <= Strings.Len(tmpVar) - 0; i++) {
if (i < Strings.Len(appName)) {
if (getPlusMinus(Strings.Mid(appName, i, 1)) == false)
{
genVal = genVal + Conversion.Val(Strings.Asc(Strings.Mid(tmpVar, i, 1)));
}
else {
genVal = genVal - Conversion.Val(Strings.Asc(Strings.Mid(tmpVar, i, 1)));
}
}
else {
if (Conversion.Int(i / 2) == i / 2) {
genVal = genVal - Conversion.Val(Strings.Asc(Strings.Mid(tmpVar, i, 1)));
}
else {
genVal = genVal + Conversion.Val(Strings.Asc(Strings.Mid(tmpVar, i, 1)));
}
}
}
if (genVal < 0) genVal = 0 - genVal;
tmpVar = tmpVar + Strings.Mid((genVal * appVal) + "TKYEH", 1, 5);
return Strings.UCase(tmpVar);
}