Advertisement
3_2004-2005 Security #148598

FabsCrypt

Crypt and decrypt a string without the standard PHP functions.

AI

KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Quellcode
original-source
<?
	// This script is (c)2001 F.Kranen http://www.odsync.net/
	// USE AT OWN RISK! 
	// This is the standard crypt key. To make it real hard for others to decode, use a long string with weird characters.
	define ( "FABS_CRYPT_STRING", "F@B$CrYpT1$D@B0mB");
	
	//! FabsCrypt class
	class FabsCrypt
	{
	
		//! This function takes a string, encodes it and returns the crypted string
		function crypt ( $str )
		{
			$crypted			= "";
			$cryptString		= FABS_CRYPT_STRING;
			
			for ( $i=0; $i<strlen($str); $i++ )
			{
				$iC					= $i % strlen ( $cryptString );
				$crypted			.= chr ( myabs ( ord ( $str[$i] ) + ord ( $cryptString[$iC] ) ) );
			}
			
			return $crypted;
		}
	
		//! This function takes a string, decodes it and returns the decrypted string
		function decrypt ( $str )
		{
			$decrypted			= "";
			$cryptString		= FABS_CRYPT_STRING;
			
			for ( $i=0; $i<strlen($str); $i++ )
			{
				$iC					= $i % strlen ( $cryptString );
				$decrypted			.= chr ( myabs ( ord ( $str[$i] ) - ord ( $cryptString[$iC] ) ) );
			}
		
			return $decrypted;
		}
	}
	//! Function needed by crypt and decrypt
	function myabs ( $i )
	{
		if ( $i > 255 )
			return $i - 255;
		else
			return $i;
	}
	
	$fabscrypt		= new FabsCrypt ( );
	
	$original		= "This is a string wich will be encrypted and hopefully decrypted :P";
	$crypted		= $fabscrypt->crypt ( $original );
	$decrypted		= $fabscrypt->decrypt ( $crypted );
	
	echo "Original: $original<BR>Crypted: $crypted<BR>Decrypted: $decrypted"
?>
Private mouse_offset As Point 
 Private Sub cmdTest_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles cmdTest.MouseDown
  mouse_offset = New Point(-e.X, -e.Y)
 End Sub
 Private Sub cmdTest_MouseMove(ByVal Sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles cmdTest.MouseMove
  If e.Button = MouseButtons.Left Then
   Dim mousePos As Point = Sender.findform().MousePosition
   mousePos.Offset(mouse_offset.X, mouse_offset.Y)
   Sender.findform().Location = mousePos
  End If
 End Sub
Originalkommentare (3)
Wiederhergestellt von der Wayback Machine