Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99026643
PhabricatorHMACTestCase.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jan 18, 14:03
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Jan 20, 14:03 (2 d)
Engine
blob
Format
Raw Data
Handle
23689168
Attached To
rPH Phabricator
PhabricatorHMACTestCase.php
View Options
<?php
final
class
PhabricatorHMACTestCase
extends
PhabricatorTestCase
{
protected
function
getPhabricatorTestCaseConfiguration
()
{
return
array
(
self
::
PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES
=>
true
,
);
}
public
function
testHMACKeyGeneration
()
{
$input
=
'quack'
;
$hash_1
=
PhabricatorHash
::
digestWithNamedKey
(
$input
,
'test'
);
$hash_2
=
PhabricatorHash
::
digestWithNamedKey
(
$input
,
'test'
);
$this
->
assertEqual
(
$hash_1
,
$hash_2
);
}
public
function
testSHA256Hashing
()
{
$input
=
'quack'
;
$key
=
'duck'
;
$expect
=
'5274473dc34fc61bd7a6a5ff258e6505'
.
'4b26644fb7a272d74f276ab677361b9a'
;
$hash
=
PhabricatorHash
::
digestHMACSHA256
(
$input
,
$key
);
$this
->
assertEqual
(
$expect
,
$hash
);
$input
=
'The quick brown fox jumps over the lazy dog'
;
$key
=
'key'
;
$expect
=
'f7bc83f430538424b13298e6aa6fb143'
.
'ef4d59a14946175997479dbc2d1a3cd8'
;
$hash
=
PhabricatorHash
::
digestHMACSHA256
(
$input
,
$key
);
$this
->
assertEqual
(
$expect
,
$hash
);
}
}
Event Timeline
Log In to Comment