次のような CodeIgniter のエンコード メソッドを使用して、ユーザー名、パスワード、およびセキュリティ トークンを保存します。
$this->load->library('encrypt');
//...
$password = $this->encrypt->encode($rows["password"]);
//Then save it in password column of user_credentials table.
さて、Pythonで、このエンコードされたパスワードをデコードしたいと思います。Python のhashlibでデコードしようとしましたが、できません。
CIの暗号化ライブラリがパスワードに対してmd5以上を行うためだと思います-
function encode($string, $key = '')
{
$key = $this->get_key($key);
if ($this->_mcrypt_exists === TRUE)
{
$enc = $this->mcrypt_encode($string, $key);
}
else
{
$enc = $this->_xor_encode($string, $key);
}
return base64_encode($enc);
}
function decode($string, $key = '')
{
$key = $this->get_key($key);
if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string))
{
return FALSE;
}
$dec = base64_decode($string);
if ($this->_mcrypt_exists === TRUE)
{
if (($dec = $this->mcrypt_decode($dec, $key)) === FALSE)
{
return FALSE;
}
}
else
{
$dec = $this->_xor_decode($dec, $key);
}
return $dec;
}
どのようにデコードすればよいですか?上記のデコード関数を Python で記述する必要があります。助けてください。