PasswordEncoder
Password encoder for microsoft office applications
Table of Contents
- ALGORITHM_HMAC = 'HMAC'
- ALGORITHM_MAC = 'MAC'
- ALGORITHM_MD2 = 'MD2'
- ALGORITHM_MD4 = 'MD4'
- ALGORITHM_MD5 = 'MD5'
- ALGORITHM_RIPEMD = 'RIPEMD'
- ALGORITHM_RIPEMD_160 = 'RIPEMD-160'
- ALGORITHM_SHA_1 = 'SHA-1'
- ALGORITHM_SHA_256 = 'SHA-256'
- ALGORITHM_SHA_384 = 'SHA-384'
- ALGORITHM_SHA_512 = 'SHA-512'
- $algorithmMapping : array<string|int, mixed>
- Mapping between algorithm name and algorithm ID
- $encryptionMatrix : mixed
- $initialCodeArray : mixed
- $passwordMaxLength : mixed
- getAlgorithmId() : int
- Returns the algorithm ID
- hashPassword() : string
- Create a hashed password that MS Word will be able to work with
- buildCombinedKey() : int
- Build combined key from low-order word and high-order word
- getAlgorithm() : string
- Get algorithm from self::$algorithmMapping
- int32() : int
- Simulate behaviour of (signed) int32
Constants
ALGORITHM_HMAC
public
mixed
ALGORITHM_HMAC
= 'HMAC'
ALGORITHM_MAC
public
mixed
ALGORITHM_MAC
= 'MAC'
ALGORITHM_MD2
public
mixed
ALGORITHM_MD2
= 'MD2'
ALGORITHM_MD4
public
mixed
ALGORITHM_MD4
= 'MD4'
ALGORITHM_MD5
public
mixed
ALGORITHM_MD5
= 'MD5'
ALGORITHM_RIPEMD
public
mixed
ALGORITHM_RIPEMD
= 'RIPEMD'
ALGORITHM_RIPEMD_160
public
mixed
ALGORITHM_RIPEMD_160
= 'RIPEMD-160'
ALGORITHM_SHA_1
public
mixed
ALGORITHM_SHA_1
= 'SHA-1'
ALGORITHM_SHA_256
public
mixed
ALGORITHM_SHA_256
= 'SHA-256'
ALGORITHM_SHA_384
public
mixed
ALGORITHM_SHA_384
= 'SHA-384'
ALGORITHM_SHA_512
public
mixed
ALGORITHM_SHA_512
= 'SHA-512'
Properties
$algorithmMapping
Mapping between algorithm name and algorithm ID
private
static array<string|int, mixed>
$algorithmMapping
= array(
self::ALGORITHM_MD2 => array(1, 'md2'),
self::ALGORITHM_MD4 => array(2, 'md4'),
self::ALGORITHM_MD5 => array(3, 'md5'),
self::ALGORITHM_SHA_1 => array(4, 'sha1'),
self::ALGORITHM_MAC => array(5, ''),
// 'mac' -> not possible with hash()
self::ALGORITHM_RIPEMD => array(6, 'ripemd'),
self::ALGORITHM_RIPEMD_160 => array(7, 'ripemd160'),
self::ALGORITHM_HMAC => array(9, ''),
//'hmac' -> not possible with hash()
self::ALGORITHM_SHA_256 => array(12, 'sha256'),
self::ALGORITHM_SHA_384 => array(13, 'sha384'),
self::ALGORITHM_SHA_512 => array(14, 'sha512'),
)
Tags
$encryptionMatrix
private
static mixed
$encryptionMatrix
= array(array(0xaefc, 0x4dd9, 0x9bb2, 0x2745, 0x4e8a, 0x9d14, 0x2a09), array(0x7b61, 0xf6c2, 0xfda5, 0xeb6b, 0xc6f7, 0x9dcf, 0x2bbf), array(0x4563, 0x8ac6, 0x5ad, 0xb5a, 0x16b4, 0x2d68, 0x5ad0), array(0x375, 0x6ea, 0xdd4, 0x1ba8, 0x3750, 0x6ea0, 0xdd40), array(0xd849, 0xa0b3, 0x5147, 0xa28e, 0x553d, 0xaa7a, 0x44d5), array(0x6f45, 0xde8a, 0xad35, 0x4a4b, 0x9496, 0x390d, 0x721a), array(0xeb23, 0xc667, 0x9cef, 0x29ff, 0x53fe, 0xa7fc, 0x5fd9), array(0x47d3, 0x8fa6, 0xf6d, 0x1eda, 0x3db4, 0x7b68, 0xf6d0), array(0xb861, 0x60e3, 0xc1c6, 0x93ad, 0x377b, 0x6ef6, 0xddec), array(0x45a0, 0x8b40, 0x6a1, 0xd42, 0x1a84, 0x3508, 0x6a10), array(0xaa51, 0x4483, 0x8906, 0x22d, 0x45a, 0x8b4, 0x1168), array(0x76b4, 0xed68, 0xcaf1, 0x85c3, 0x1ba7, 0x374e, 0x6e9c), array(0x3730, 0x6e60, 0xdcc0, 0xa9a1, 0x4363, 0x86c6, 0x1dad), array(0x3331, 0x6662, 0xccc4, 0x89a9, 0x373, 0x6e6, 0xdcc), array(0x1021, 0x2042, 0x4084, 0x8108, 0x1231, 0x2462, 0x48c4))
$initialCodeArray
private
static mixed
$initialCodeArray
= array(0xe1f0, 0x1d0f, 0xcc9c, 0x84c0, 0x110c, 0xe10, 0xf1ce, 0x313e, 0x1872, 0xe139, 0xd40f, 0x84f9, 0x280c, 0xa96a, 0x4ec3)
$passwordMaxLength
private
static mixed
$passwordMaxLength
= 15
Methods
getAlgorithmId()
Returns the algorithm ID
public
static getAlgorithmId(string $algorithmName) : int
Parameters
- $algorithmName : string
Return values
int —hashPassword()
Create a hashed password that MS Word will be able to work with
public
static hashPassword(string $password[, string $algorithmName = self::ALGORITHM_SHA_1 ][, string $salt = null ][, int $spinCount = 10000 ]) : string
Parameters
- $password : string
- $algorithmName : string = self::ALGORITHM_SHA_1
- $salt : string = null
- $spinCount : int = 10000
Tags
Return values
string —buildCombinedKey()
Build combined key from low-order word and high-order word
private
static buildCombinedKey(array<string|int, mixed> $byteChars) : int
Parameters
- $byteChars : array<string|int, mixed>
-
byte array representation of password
Return values
int —getAlgorithm()
Get algorithm from self::$algorithmMapping
private
static getAlgorithm(string $algorithmName) : string
Parameters
- $algorithmName : string
Return values
string —int32()
Simulate behaviour of (signed) int32
private
static int32(int $value) : int
Parameters
- $value : int