Ejemplo n.º 1
0
function encoder($x)
{
    $value = new hash_encryption($keypass1);
    $first = $value->encrypt($x);
    $first_output = '';
    $count = 0;
    while ($count < strlen($encrypted)) {
        $enc_output .= substr($first, $count, 80) . "<br>";
        $count += 80;
    }
    $Cipher = new AES();
    $key_256bit = $keypass;
    $n = ceil(strlen($first) / 16);
    $encrypt = "";
    for ($i = 0; $i <= $n - 1; $i++) {
        $cryptext = $Cipher->encrypt($Cipher->stringToHex(substr($first, $i * 16, 16)), $key_256bit);
        $encrypt .= $cryptext;
    }
    return $encrypt;
}
Ejemplo n.º 2
0
 function securityEncryptString($plaintext)
 {
     $plaintext = CI::library('encrypt')->encode($plaintext);
     $plaintext = base64_encode($plaintext);
     return $plaintext;
     /*$the_pass = $this->optionsGetByKey ( 'ecnryption_hash', true );
     
     		$do_the_pass_needs_change = strtotime ( $the_pass ['updated_on'] );
     		$yesterday = strtotime ( date ( "Y-m-d H:i:s", time () - 86400 ) );
     
     		$the_pass = $the_pass ['option_value'];
     
     		if ($yesterday > $do_the_pass_needs_change) {
     			$the_pass = false;
     			$this->optionsDeleteByKey ( 'ecnryption_hash' );
     		}
     
     		if (($the_pass) == false) {
     			$the_pass = rand () . rand ();
     			$new_key = array ();
     			$new_key ['option_key'] = 'ecnryption_hash';
     			$new_key ['option_value'] = $the_pass;
     			$new_key ['option_group'] = 'security';
     			$this->optionsSave ( $new_key );
     		}*/
     //$the_pass = intval ( $the_pass );
     $string = $plaintext;
     require_once 'crypt/class.hash_crypt.php';
     $the_pass = CI::library('session')->userdata('session_id');
     $crypt = new hash_encryption($the_pass);
     $encrypted = $crypt->encrypt($plaintext);
     return $encrypted;
 }
Ejemplo n.º 3
0
				</td>
			</tr>
		</table>
		<input type="submit" name="encrypt" value="Encrypt playintext" />
	</form>
	<hr>
<?php 
// Did the user submit our form?
if (isset($_POST['encrypt'])) {
    $html = '';
    // Include class file
    require_once 'class.hash_crypt.php';
    // Instantiate new hash_encryption object, feed password
    $crypt = new hash_encryption($password);
    // Do the encryption
    $encrypted = $crypt->encrypt($plaintext);
    // Convert ciphertext for convenient screen presentation: add linebreak every 80 chars
    $encrypted_output = '';
    $count = 0;
    while ($count < strlen($encrypted)) {
        $encrypted_output .= substr($encrypted, $count, 80) . "<br>";
        $count += 80;
    }
    // Prepare html output
    $html .= '<p>Ciphertext:</p>';
    $html .= '<p style="border: 1px solid black">' . $encrypted_output . '</p>';
    $html .= '<p>By the way: The ciphertext decrypts to the following message using your password "' . htmlentities($password) . '":</p>';
    // Let's decrypt the ciphertext again
    $decrypted = $crypt->decrypt($encrypted);
    $html .= '<p style="border: 1px solid black">' . $decrypted . '</p>';
    $html .= '<h1 style="font-size:16px">Tip: Try to encrypt your plaintext using the same key several times. You will see that it will generate different ciphertext every time.</h1>';