base64 encode/decode, and random hashes

This commit is contained in:
Adam Backstrom 2012-07-10 10:25:18 -04:00
parent 347fd6f3c9
commit 1c435f5460
3 changed files with 43 additions and 0 deletions

View File

@ -53,6 +53,36 @@ class ActionQuotedPrintableDecode extends AbstractAction
}
}
class ActionBase64Encode extends AbstractAction
{
public function __construct( $value )
{
parent::__construct( $value );
$this->setContainer( new TextareaContainer );
$this->setFormatter( new EchoFormatter );
}
public function decode()
{
return base64_encode( $this->value );
}
}
class ActionBase64Decode extends AbstractAction
{
public function __construct( $value )
{
parent::__construct( $value );
$this->setContainer( new TextareaContainer );
$this->setFormatter( new EchoFormatter );
}
public function decode()
{
return base64_decode( $this->value );
}
}
class ActionUrldecode extends AbstractAction
{
public function __construct( $value )

View File

@ -37,6 +37,8 @@ if( 'POST' === $_SERVER['REQUEST_METHOD'] ) {
<option value="Urlencode" <?php echo selected($_POST['action'], 'Urlencode'); ?>>urlencode()</option>
<option value="Urldecode"<?php echo selected($_POST['action'], 'Urldecode'); ?>>urldecode()</option>
<option value="Unserialize"<?php echo selected($_POST['action'], 'Unserialize'); ?>>unserialize()</option>
<option value="Base64Decode"<?php echo selected($_POST['action'], 'Base64Decode'); ?>>base64_decode()</option>
<option value="Base64Encode"<?php echo selected($_POST['action'], 'Base64Encode'); ?>>base64_encode()</option>
<select>
<input type="submit">
</form>
@ -44,5 +46,12 @@ if( 'POST' === $_SERVER['REQUEST_METHOD'] ) {
<?php if( $action ) echo $action; ?>
</div>
<h2>Randomness</h2>
<ul>
<li>MD5: <input class="randomness-box" value="<?php echo md5(uniqid(mt_rand(), true)); ?>"></li>
<li>SHA1: <input class="randomness-box" value="<?php echo sha1(uniqid(mt_rand(), true)); ?>"></li>
</ul>
</body>
</html>

View File

@ -22,3 +22,7 @@ h2 {
float: left;
padding: 10px;
}
.randomness-box {
width: 30em;
}