[.Net/MSIL] XOR encryption

01/26/2014 17:57 tolio#1
Sollte selbsterklärend sein, zwei byte arrays rein, eins raus

Code:
.method public static uint8[] xorit (uint8[] input, uint8[] key) cil managed
{
	.locals init(
		[0] int32 i,
		[1] int32 a,
		[2] int32 b
	)
	
	ldc.i4.0 
	stloc.0 //i = 0
	ldarg.0 
	ldlen  
	ldc.i4.1 
	sub 
	stloc.1 //a = input.length - 1
	ldarg.1
	ldlen
	stloc.2 //b = key.length
	br CHECK
	
	LOOP:
	ldarg.0
	ldloc.0
	ldarg.0
	ldloc.0
	ldelem.u1 //load intput[i] as int32
	ldarg.1
	ldloc.0
	ldloc.2
	rem
	ldelem.u1 //load key[i MOD b] as int32
	xor //intput[i] XOR key[i MOD b]
	stelem.i1 //save in input[i] as uint8
	ldloc.0
	ldc.i4.1
	add
	stloc.0 //i = i + 1

	CHECK:
	ldloc.0 //i
	ldloc.1 //a
	bne.un LOOP // i != a ?
	
	ldarg.0
	ret //return input
}
01/27/2014 23:49 3Angle#2
Kann man schön mit Mono.Cecil verwenden!
Aber selbsterklärend ist das nur für Fortgeschrittene ;)
01/28/2014 10:50 tolio#3
Quote:
Originally Posted by 3Angle View Post
Kann man schön mit Mono.Cecil verwenden!
Aber selbsterklärend ist das nur für Fortgeschrittene ;)
Habs auch letzten Endes für die verwendung mit mono cecil zusammengebaut ;)