phpass 64 kodlamak temel almak encode64() tuhaf (bana) bir algoritma kullanır. Base64 ve Uuencode, yazdırılabilir bir karaktere eşlemeden önce her sekizli üretmek için 6 bitlik bilyeli yığın. encode64
etrafında bit karıştırır:phpass'ın özel base 64 enkoder: Base64 üzerinde bir adı/avantajı var mı?
input bit location: abcdefgh ijklmnop qrstuvwx
base64 bit location: ..abcdef ..ghijkl ..mnopqr ..stuvwx
encode64 bit location: ..cdefgh ..mnopab ..wxijkl ..qrstuv
bu algoritma yaygın bilinen mı? Ve geriye dönük uyumluluğun yanı sıra, neden Base64 üzerinden seçmelisiniz?
Ben algoritma netleştirmek için yeniden yazıldı belirttik: ''
function encode64($input, $bytesToProcess)
{
// convert to array of ints
for ($i = 0; $i < $bytesToProcess; $i++) {
$bytes[] = ord($input[$i]);
}
$octets = array();
$i = 0;
do {
$value = $bytes[$i++];
$octets[] = $value & 0x3f;
if ($i < $bytesToProcess) {
$value |= $bytes[$i] << 8;
}
$octets[] = ($value >> 6) & 0x3f;
if ($i++ >= $bytesToProcess) {
break;
}
if ($i < $bytesToProcess) {
$value |= $bytes[$i] << 16;
}
$octets[] = ($value >> 12) & 0x3f;
if ($i++ >= $bytesToProcess) {
break;
}
$octets[] = ($value >> 18) & 0x3f;
} while ($i < $bytesToProcess);
return array_map(function ($i) {
return str_pad(base_convert($i, 10, 2), 6, '0', STR_PAD_LEFT);
}, $octets);
}
var_export(encode64("Man", 3));
[Drupal noktası] (http://drupalcode.org/project/drupal.git/blob/refs/heads/7.x:/includes/password.inc#l46) dan "* Nix standart olarak tanımlamaktadır crypt()" her iki ucunda da birer bayt takas yapıyor gibi görünüyor bana –