Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
 
2
<?php
3
// Verschlüsselungsalgorithmus
4
function pre($_x)
5
{
6
	print( "<pre>" );
7
	print_r($_x);
8
	print( "</pre>" );
9
}
10
 
11
// test
12
$a[]="01012005120053";
13
$a[]="100.00";
14
$a[]="markus@niewerth.com";
15
 
16
foreach(array_keys($a) AS $elem)
17
{
18
	$b[$elem] = sprintf("%u",crc32(md5($a[$elem])));
19
	$b[$elem] = wordwrap( $b[$elem] , 2 , "###", 1);
20
	$a_[$elem] = explode("###",$b[$elem]);
21
}
22
 
23
foreach(array_keys($a_) as $elem)
24
{
25
	foreach(array_keys($a_[$elem]) as $key)
26
	{
27
		$x[]=dechex($a_[$elem][$key]);
28
	}
29
}
30
 
31
$key="";
32
 
33
for($i=0;$i<count($x);$i++)
34
{
35
	$key .= strtoupper($x[$i]).( ($i%5==0 && $i!=0) ? "-" : "");
36
}
37
 
38
pre($key);
39
 
40
 
41
?>
42
<form name="form1" method="post" action="">
43
  <input name="code" type="text" id="code">
44
  <input type="submit" name="submit" value="Abschicken">
45
</form>
46
 
47
<?
48
	if($_POST['submit'])
49
	{
50
		// Ncode
51
		$ncode="";
52
		$code = str_replace("-", "", $_POST['code']);
53
		$code = wordwrap( $code , 2 , "###", 1);
54
		$code = explode("###",$code);
55
		foreach(array_keys($code) AS $elem)
56
		{
57
			$ncode.=hexdec($code[$elem]);
58
		}
59
 
60
		$ncode = wordwrap( $ncode , 10 , "-", 1);
61
		$ncode = explode( "-", $ncode );
62
		$ncode = $ncode[0]."-".$ncode[1]."-".$ncode[2];
63
		// Vcode
64
		foreach(array_keys($a) AS $elem)
65
		{
66
			$b[$elem] = sprintf("%u",crc32(md5($a[$elem])));
67
		}
68
		$vcode = $b[0]."-".$b[1]."-".$b[2];
69
		echo "NCode:$ncode<br>";
70
		echo "VCode:$vcode<br>";
71
		if($ncode!=$vcode) { echo "Der code war nicht richtig!"; }else{ echo "Dies war ein gülltiger code"; }
72
	}
73
?>
74
 
75
<? show_source(__FILE__) ?>