[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/phpseclib/phpseclib/phpseclib/Crypt/ -> DES.php (summary)

Pure-PHP implementation of DES. Uses mcrypt, if available, and an internal implementation, otherwise.

Author: Jim Wigginton
Copyright: 2007 Jim Wigginton
License: http://www.opensource.org/licenses/mit-license.html MIT License
Link: http://phpseclib.sourceforge.net
File Size: 1443 lines (71 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

DES:: (7 methods):
  isValidEngine()
  setKey()
  _encryptBlock()
  _decryptBlock()
  _processBlock()
  _setupKey()
  _setupInlineCrypt()


Class: DES  - X-Ref

Pure-PHP implementation of DES.

isValidEngine($engine)   X-Ref
Test for engine validity

This is mainly just a wrapper to set things up for \phpseclib\Crypt\Base::isValidEngine()

param: int $engine
see: \phpseclib\Crypt\Base::isValidEngine()
return: bool

setKey($key)   X-Ref
Sets the key.

Keys can be of any length.  DES, itself, uses 64-bit keys (eg. strlen($key) == 8), however, we
only use the first eight, if $key has more then eight characters in it, and pad $key with the
null byte if it is less then eight characters long.

DES also requires that every eighth bit be a parity bit, however, we'll ignore that.

If the key is not explicitly set, it'll be assumed to be all zero's.

param: string $key
see: \phpseclib\Crypt\Base::setKey()

_encryptBlock($in)   X-Ref
Encrypts a block

param: string $in
see: \phpseclib\Crypt\Base::_encryptBlock()
see: \phpseclib\Crypt\Base::encrypt()
see: self::encrypt()
return: string

_decryptBlock($in)   X-Ref
Decrypts a block

param: string $in
see: \phpseclib\Crypt\Base::_decryptBlock()
see: \phpseclib\Crypt\Base::decrypt()
see: self::decrypt()
return: string

_processBlock($block, $mode)   X-Ref
Encrypts or decrypts a 64-bit block

$mode should be either self::ENCRYPT or self::DECRYPT.  See
{@link http://en.wikipedia.org/wiki/Image:Feistel.png Feistel.png} to get a general
idea of what this function does.

param: string $block
param: int $mode
see: self::_encryptBlock()
see: self::_decryptBlock()
return: string

_setupKey()   X-Ref
Creates the key schedule

see: \phpseclib\Crypt\Base::_setupKey()

_setupInlineCrypt()   X-Ref
Setup the performance-optimized function for de/encrypt()

see: \phpseclib\Crypt\Base::_setupInlineCrypt()