Browse Source

base64 encode/decode, and random hashes

master
Adam Backstrom 10 years ago
parent
commit
1c435f5460
  1. 30
      classes.php
  2. 9
      index.php
  3. 4
      style.css

30
classes.php

@ -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 )

9
index.php

@ -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>

4
style.css

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

Loading…
Cancel
Save