简体   繁体   中英

PHP crypt string

I try to crypt the sso ticket on my flash game.

var flashvars = {
"sso.ticket" : "<?PHP echo TicketRefresh($user['username']); ?>" };

This is the part of the code i've tried to encrypt it

function encrypt($pure_string, $encryption_key) {
$iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$encrypted_string = mcrypt_encrypt(MCRYPT_BLOWFISH, $encryption_key,
utf8_encode($pure_string), MCRYPT_MODE_ECB, $iv);
return $encrypted_string;
}

<?php
define("ENCRYPTION_KEY", "!@#$%^&*");
$string = TicketRefresh($user['username']);
$encrypted = encrypt($string, ENCRYPTION_KEY);
?>

var flashvars = {
"sso.ticket" : "<?PHP echo $encrypted; ?>" };

I am a beginner and I don't know what is wrong with it, thank you for your help.

Encrypt is not a PHP function

crypt is one, that should be used with a salt for more security:

$encrypted = crypt($string, $longSalt);

I recommend you to use a $longSalt of random characters of 10 or more characters

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM