Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Java
function algo() {
	return {		
		keygen: {
			userId: null,
			gameId: null,
			tableId: null,
			temp: null,
			resultNum1: new Array,
			resultNum2: new Array,
			resultNum3: new Array,
			resultNum12: new Array,
			resultNum23: new Array,
			resultNum123: new Array,
			resultChar1: new Array,
			resultChar2: new Array,
			resultChar3: new Array,
			resultChar12: new Array,
			resultChar23: new Array,
			resultChar123: new Array,
			setGameId: function (A) {
				this.gameId = A
			},
			init: function (A, g, I) {
				this.userId = A,
				this.gameId = g || this.gameId,
				this.tableId = I,
				temp = "",
				this.resultNum1 = this.numFunc(this.userId),
				this.resultNum2 = this.numFunc(this.gameId),
				this.resultNum3 = this.numFunc(this.tableId),
				this.resultNum12 = this.ooxoroo(this.resultNum1, this.resultNum2),
				this.resultNum123 = this.ooxoroo(this.resultNum12, this.resultNum3);
				for (var B = new Array, t = 0; t < 4; t++) B[t] = String.fromCharCode(Number(this.resultNum123[t]) + 97);
				this.resultChar1 = this.charFunc(this.userId),
				this.resultChar2 = this.charFunc(this.gameId),
				this.resultChar3 = this.charFunc(this.tableId);
				for (var e = 0; e < 4; e++) this.resultChar3[e] = Number(this.resultChar3[e]) - 97;
				this.resultChar12 = this.ooxoroo(this.resultChar1, this.resultChar2),
				this.resultChar123 = this.ooxoroo(this.resultChar12, this.resultChar3);
				for (var s = new Array, i = 0; i < 4; i++) Number(this.resultChar123[i]) > 9 ? (s[i] = Math.floor(Number(this.resultChar123[i]) / 10 + Number(this.resultChar123[i])), Number(s[i]) >= 10 && (s[i] = 9)) : s[i] = Math.floor(this.resultChar123[i]);
				var a = new Array;
				a = B.concat(s);
				for (var r = 0; r < a.length; r++) temp = temp + "" + a[r];
				return temp
			},
			numFunc: function (A) {
				var g, I = 0,
				B = new Array,
				t = (new Array, new Array);
				g = A.length;
				for (var e = 0; e < g; e++) A.charCodeAt(e) >= 48 && A.charCodeAt(e) <= 57 && A.charAt(e) != A.charAt(e - 1) && (B[I] = A.charAt(e), I++);
				for (e = 0; e < B.length; e++) for (var s = 0; s < B.length; s++) e != s && B[e] == B[s] && B.splice(s < e ? e: s, 1);
				if ((t = B.splice(0, 4)).length < 4) {
					for (var i = t.length; i < 4; i++) t.push("0");
					return t
				}
				return t
			},
			ooxoroo: function (A, g) {
				for (var I = new Array, B = 0; B < 4; B++) I[B] = A[B] ^ g[B];
				return I
			},
			charFunc: function (A) {
				for (var g = new Array, I = new Array, B = new Array, t = A, e = 0, s = 0; s < t.length; s++) 115 != t.charCodeAt(s) && 105 != t.charCodeAt(s) && 116 != t.charCodeAt(s) && 97 != t.charCodeAt(s) && 110 != t.charCodeAt(s) || t.charAt(s) != t.charAt(s - 1) && (g[e] = t.charAt(s), e++);
				for (var i = 0; i < g.length; i++) for (var a = 0; a < g.length; a++) i != a && g[i] == g[a] && g.splice(a < i ? i: a, 1);
				if ((I = g.splice(0, 4)).length < 4) for (var r = I.length; r < 4; r++) I.push("u");
				for (var Q = 0; Q < 4; Q++) B[Q] = Number(I[Q].charCodeAt(0));
				return B
			}
		}
	}
}


What I have tried:

I want to change the above code to full C# code.

Sorry for not knowing Java

There are many things I don't understand.

Please
Posted
Updated 22-Jan-21 21:02pm

This is not a code conversion service: we are not here to translate code for you.
Even if we did, what you would end up with would not be "good code" in the target language – they are based on very different frameworks, and what makes something work in one language does not always "translate" directly into another.
So what you end up with is very poor code, that is difficult if not impossible to maintain, that can’t be upgraded nicely, and that will cause you immense headaches if the original is changed. And it’ll be a nightmare to debug if it doesn’t work "straight out of the box".
Instead, use the source code as a specification for a new app written in and for the target language / framework and write it from scratch using the original as a "template". You will get a much, much better result that will save you a lot of time in the long run.
 
Share this answer
 
Java is similar enough, just paste the code in and change it until it works.

ooxoroo: function (A, g)


This is not C# though.
 
Share this answer
 
Java code
Java
ooxoroo:function(A,g){
    for(var I=new Array,B=0;B<4;B++)
        I[B]=A[B]^g[B];
    return I
}


C# convert
C#
static int[] ooxoroo(int[] A, int[] g)
{
    int[] I = new int[4];
    int B;

    for (B = 0; B < 4; B++)
    {
        I[B] = A[B] ^ g[B];
    }
    return I;
}



Java
numFunc:function(A){
    var g,I=0,
    B=new Array,
    t=(new Array,new Array); C# convert code ??
    g=A.length;

    for(var e=0;e<g;e++)
    A.charCodeAt(e)>=48&&A.charCodeAt(e)<=57&&A.charAt(e)!=A.charAt(e-1)&&(B[I]=A.charAt(e),I++);
        for(e=0;e<B.length;e++)
        for(var s=0;s<B.length;s++)e!=s&&B[e]==B[s]&&B.splice(s<e?e:s,1);
        if((t=B.splice(0,4)).length<4){
        for(var i=t.length;i<4;i++)t.push("0");
        return t
    }
    return t
}


Please teach me

Sorry. bad English
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900