PHP.mk документација

gmp_xor

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.gmp-xor.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.gmp-xor.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
gmp_xor

Референца за `function.gmp-xor.php` со подобрена типографија и навигација.

function.gmp-xor.php

gmp_xor

(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)

gmp_xorBitwise XOR

= NULL

gmp_xor(GMP|int|string $num1, GMP|int|string $num2): GMP

Го пресметува бинарното ексклузивно ИЛИ (XOR) на два GMP броја.

Параметри

num1

А GMP објект, еден int, или string што може да се толкува како број следејќи ја истата логика како да се користел стринг во gmp_init() со автоматско откривање на база (т.е. кога base е еднакво на 0).

num2

А GMP објект, еден int, или string што може да се толкува како број следејќи ја истата логика како да се користел стринг во gmp_init() со автоматско откривање на база (т.е. кога base е еднакво на 0).

Вратени вредности

А GMP object.

Примери

Пример #1 gmp_xor() example

<?php
$xor1
= gmp_init("1101101110011101", 2);
$xor2 = gmp_init("0110011001011001", 2);

$xor3 = gmp_xor($xor1, $xor2);

echo
gmp_strval($xor3, 2) . "\n";
?>

Пример #1 Пример што покажува затворачка ознака што го опфаќа последниот нов ред

1011110111000100

Белешки од корисници 5 белешки

kimcbrowne на hotmail точка com
20 години пред
To be unbreakable XOR encryption must have a key that is totally random and is never re-used.  If you use a key a second time, it can be broken.  This can be confirmed by reading the page at http://en.wikipedia.org/wiki/One-time_pad.

Although I am not an expert on cryptography, I understand that decyphering involves recognizing patterns and that it would be possible to decrypt code that was encoded using XOR with the same key if there were enough samples to examine.  Maintaining unique keys for each encryption at both encryption and decryption points to ensure 100 percent unbreakability has security problems of its own - where and how are the keys stored and how are they transmitted to the decryption points?
bukaj на bukaj точка net
20 години пред
XOR encryption is an ultimate encryption algorithm. It can't be be broken. It is used to encrypt stealth submarine's orders. I cannot agree with "kid-sister" post below. If you use vast key (as long as encrypted message) which is random (space noise recorded on a cd), the encrypted message is also radnom - impossible to decrypt without key. Under those conditions, XOR is strongest encryption algorithm ever known.
patm на pureconnection точка net
пред 22 години
XOR encryption only works if the key is at liest the same size as the plaintext, and the key is perfectly random. And no, rand() is not perfectly random.
mikko на entris точка net
пред 23 години
The logical XOR can be used for encrypting data. Use resource A as your original text and resource B as the key. Be sure to use long enough key so that the key doesn't loop. Decryption works the same way, input encrypted text as res A and key as res B.
greenone
пред 17 години
here's a fast alternative to compute the xor-value of two bitstrings of an arbitrary (but same) length.

<?php
/**
 * xor-op for bitstrings of arbitrary length
 * bitstrings must have same length
 * 
 * @param string $o1
 * @param string $o2
 * @return string
 */
function bitxor($o1, $o2) {
    $xorWidth = PHP_INT_SIZE*8;
    $o1 = str_split($o1, $xorWidth);
    $o2 = str_split($o2, $xorWidth);
    $res = '';
    $runs = count($o1);
    for($i=0;$i<$runs;$i++)
        $res .= decbin(bindec($o1[$i]) ^ bindec($o2[$i]));        
    return $res;
}
?>
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.