最近经常与编码这方面打交道。每次用到rot13编码时都得去Baidu在线编解码。次数多了,就觉得繁琐了,于是就想写个PHP脚本实现。为了方便自己。后来发现网上已经有人写了,于是稍微改写了代码如下:
<?php
function _encode($code) {
$encode = str_rot13($code);
return $encode;
}
function _decode($code) {
$decode = str_rot13($code);
return $decode;
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<meta charset="utf-8">
<title>Rot13编码/解码</title>
<link rel="alternate" title="CrazyOf.me" href="http://ixyzero.com/blog/feed" type="application/rss+xml" />
<style type="text/css" media="all">
html, body {margin: 0;padding: 0; }body {color: #333;font: 12px Tahoma,Lucida Grande, sans-serif;margin: 9%;}a {color: #0055CC; }img {border: 0px solid #CCC;}h1 {margin: 0;}h3 {color: #555;font-size: 1.6em;font-weight: normal;margin: 0; }pre {color: #0055CC;font-size: 1.1em;line-height: 1.2;margin: 0.25em 0; }p {margin: 0.65em 0;}#ads {border-left: 1px solid #eee;float: right;margin: 0 0 2em 2.5em;padding-left: 3px;width: 160px;}#source {margin-bottom: 2.5em; }pre {overflow: auto;padding:1em 0; }h2 {position: relative;top: 0.5em;}
</style>
<h3>Rot13加密/解密</h3>
<form method="post">
<textarea name="source" cols="55" rows="8">
<?php
if(!empty($_POST['source'])) {
if($_POST['button']=='编码') {
echo htmlspecialchars(_encode(stripcslashes($_POST['source'])));
}
if($_POST['button']=='解码') {
echo htmlspecialchars(_decode(stripcslashes($_POST['source'])));
}
}
?>
</textarea>
<?php
if(!empty($_POST['source'])){
if($_POST['button']=='编码') {
echo '
编码成功.';
}
if($_POST['button']=='解码') {
echo '
解码成功.';
}
}else{
echo '
ROT13 编码简单地使用字母表中后面第 13 个字母替换当前字母,同时忽略非字母表中的字符。在PHP中 ROT13 编码和解码都使用相同的函数 str_rot13() ,传递一个编码过的字符串作为参数,将得到原始字符串。';
}
?>
<input type="submit" name="button" value="编码">
<input type="submit" name="button" value="解码">
</form>
<h3>Just for fun.</h3>
放在网站的某个工具集目录下(比如:tools),时间长了、收集的工具脚本多了之后都可作为一个(简单的)工具套装方便使用。
《 “Rot13编解码的PHP脚本[bak]” 》 有 4 条评论
PHP 加密安全开发
https://paragonie.com/blog/2017/02/cryptographically-secure-php-development
配置驱动的PHP安全建议是有害的
https://paragonie.com/blog/2017/01/configuration-driven-php-security-advice-considered-harmful
在线编解码的工具大全(CyberChef:The Cyber Swiss Army Knife)
https://gchq.github.io/CyberChef/
https://github.com/gchq/CyberChef
16进制到文本字符串的转换,在线实时转换
http://www.bejson.com/convert/ox2str/
`
有时在查看audit产生的日志文件中会有十六进制字符串表示的命令,可能会用到这个在线工具进行转换。
`
cyber-chef-recipes – 包含大量编码解密等工具的项目收集
https://github.com/mattnotmax/cyber-chef-recipes