久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 PHP 中取消加密/重新加密 ColdFusion 加密字符串

Un-encrypting / re-encrypting a ColdFusion encrypted string in PHP(在 PHP 中取消加密/重新加密 ColdFusion 加密字符串)
本文介紹了在 PHP 中取消加密/重新加密 ColdFusion 加密字符串的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我處于一種令人羨慕的境地,我必須使用現(xiàn)有的 ColdFusion 應(yīng)用程序來維護功能.作為登錄過程的一部分,Coldfusion 應(yīng)用程序會存儲一個帶有加密字符串的 cookie.

I'm in the unenviable position where I have to maintain functionality with an existing ColdFusion application. As part of it's login process the Coldfusion app stores a cookie with an encrypted string.

encrypt(strToEncrypt, theKey, "AES", "Base64")

我可以使用 MCrypt 和以下代碼在 PHP 中成功解密此字符串

I can successfully decrypt this string in PHP using MCrypt and the following code

mcrypt_decrypt(
    MCRYPT_RIJNDAEL_128,
    base64_decode($theKey),
    base64_decode($encrypted_string),
    MCRYPT_MODE_ECB, "0000000000000000")

我現(xiàn)在需要在 PHP 中執(zhí)行相同的加密,以便 ColdFusion 應(yīng)用程序可以訪問 cookie 中的數(shù)據(jù).

I now have the need to perform the same encryption within PHP so that the ColdFusion app can access the data in the cookie.

目前我擁有的是

mcrypt_encrypt( MCRYPT_RIJNDAEL_128, base64_decode($theKey), $strToEncrypt, MCRYPT_MODE_ECB, "0000000000000000");

然而,這與等效的 ColdFusion 加密算法不兼容

This, however, is incompatible with the equivalent ColdFusion encryption algorithm

decrypt(strToDecrypt, theKey, "AES", "Base64")

拋出一個給定的最終塊沒有正確填充錯誤.

非常感謝任何幫助.

詹姆斯

推薦答案

不知道這會有多大幫助,但我已經(jīng)完成了以下工作.我認為為了讓 CF 開心,你必須將你的加密填充到一定的長度

Don't know how much help this will be but I have had the following working. I think to make CF happy you have to pad your encryption to a certain length

在 CF 中加密

Encrypt(data, encKey, 'AES/CBC/PKCS5Padding', encoding, encIv)

PHP 中的解密

function Decode($data, $encKey, $encIv, $format = 'uu') {
    if ($format === 'uu') {
        $data = Convert_uudecode($data);
    } else if ($format === 'hex') {
        $data = Pack('H*', $data);
    } else if ($format === 'base64') {
        $data = Base64_Decode($data);
    } else if ($format === 'url') {
        $data = UrlDecode($data);
    }
    $data = MCrypt_decrypt(MCRYPT_RIJNDAEL_128, $encKey, $data, 'cbc', $encIv);
    $pad = Ord($data{strlen($data)-1});
    if ($pad > strlen($data)) return $data;
    if (strspn($data, chr($pad), strlen($data) - $pad) != $pad) return $data;
    return substr($data, 0, -1 * $pad); 
}

PHP 加密

function Encode($data, $encKey, $encIv, $format = 'uu') {
    $pad = 16 - (StrLen($data) % 16);
    if ($pad > 0) {
        $data .= Str_repeat(Chr($pad), $pad);
    }
    $data = MCrypt_encrypt(MCRYPT_RIJNDAEL_128, $encKey, $data, 'cbc', $encIv);
    if ($format === 'uu') {
        return Convert_uuencode($data);
    } else if ($format === 'hex') {
        return Bin2Hex($data);
    } else if ($format === 'base64') {
        return Base64_Encode($data);
    } else if ($format === 'url') {
        return UrlEncode($data);
    }
}

在 CF 中解密

Decrypt(data, encKey, 'AES/CBC/PKCS5Padding', encoding, encIv)

由于某種我不記得的原因,我傾向于使用uu"作為編碼.

For some reason that I can't remember, I favoured 'uu' for the encoding.

這篇關(guān)于在 PHP 中取消加密/重新加密 ColdFusion 加密字符串的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設(shè)置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數(shù)組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產(chǎn)生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 国产欧美一区二区三区在线看 | 日韩精品免费视频 | 久草资源在线 | 一区二区三区国产 | 精品国产99| 国产成人精品免高潮在线观看 | 午夜看片 | 久久四虎| 欧美另类视频 | 可以免费观看的av | 91看片免费 | 日韩视频免费看 | 亚洲人人 | 国产精品视频一 | 久久综合影院 | 日韩精品久久久久 | 天堂在线www | 亚洲人人舔人人 | 天天色天天射天天干 | 免费h在线 | 精品国产一区二区国模嫣然 | 日韩一区二区视频 | 亚州精品成人 | 黄免费观看视频 | 久久久久国产精品一区 | 精品久久久久久久 | 久久久久久久久久久国产 | 在线看免费 | 一区二区中文字幕 | 久久精品视频免费看 | 久久免费精品 | 欧美一级黄色片免费观看 | 毛片在线免费 | 免费在线观看黄色av | 国产一区二 | 久久亚洲国产 | 亚洲第一在线 | 国产乱码精品一品二品 | 久久久噜噜噜久久中文字幕色伊伊 | 国产精品.xx视频.xxtv | 午夜精品视频 |