rendered paste body public function cryptography( $string, $key, $method )
{
if ( $method == "encrypt" )
{
return $this->cryptography_encrypt( $string, $key );
}
else
{
return $this->cryptography_decrypt( $string, $key );
}
}
private function cryptography_encrypt( $string, $key )
{
$adjust_vals = $this->cryptography_gen_key( $key );
$final_string = "";
$factor_2 = 0;
while ( strlen( $string ) < $this->hash_length )
{
$string .= ' ';
}
for ( $i = 0; $i < strlen( $string ); $i++ )
{
$char_1 = substr( $string, $i, 1);
$num_1 = strpos( $this->salt_1, $char_1 );
$adjust_val = array_shift( $adjust_vals );
$adjust_val = $adjust_val + 3;
$adjust_val_array[] = $adjust_val;
$factor = $factor_2 + $adjust_val;
$num_2 = round( $factor ) + $num_1;
$num_2 = $this->cryptography_check( $num_2 );
$factor_2 = $factor + $num_2;
$char_2 = substr( $this->salt_2, $num_2, 1 );
$final_string .= $char_2;
}
return $final_string;
}
private function cryptography_decrypt( $string, $key )
{
$adjust_vals = $this->cryptography_gen_key( $key );
$final_string = "";
$factor_2 = 0;
while ( strlen( $string ) < $this->hash_length )
{
$string .= ' ';
}
for ( $i = 0; $i < strlen( $string ); $i++ )
{
$char_2 = substr( $string, $i, 1);
$num_2 = strpos( $this->salt_2, $char_2 );
$adjust_val = array_shift( $adjust_vals );
$adjust_val = $adjust_val + 3;
$adjust_val_array[] = $adjust_val;
$factor = $factor_2 + $adjust_val;
$num_1 = $num_2 - round( $factor );
$num_1 = $this->cryptography_check( $num_1 );
$factor_2 = $factor + $num_2;
$char_1 = substr( $this->salt_1, $num_1, 1 );
$final_string .= $char_1;
}
return rtrim( $final_string );
}
private function cryptography_gen_key( $key )
{
$array[] = strlen($key);
$tot = 0;
for ($i = 0; $i < strlen($key); $i++) {
$char = substr($key, $i, 1);
$num = strpos($this->salt_1, $char);
$array[] = $num;
$tot = $tot + $num;
} // for
$array[] = $tot;
return $array;
}