根据加密方法推算解密方法,补全如下

<script>
/**
* Pseudo md5 hash function
* @param {string} string
* @param {string} method The function method, can be 'ENCRYPT' or 'DECRYPT'
* @return {string}
*/
function pseudoHash(string, method) {
// Default method is encryption
if (!('ENCRYPT' == method || 'DECRYPT' == method)) {
method = 'ENCRYPT';
}
// Run algorithm with the right method
if ('ENCRYPT' == method) {
// Variable for output string
var output = '';
// Algorithm to encrypt
for (var x = 0, y = string.length, charCode, hexCode; x < y; ++x) {
charCode = string.charCodeAt(x);
if (128 > charCode) {
charCode += 128;
} else if (127 < charCode) {
charCode -= 128;
}
charCode = 255 - charCode;
hexCode = charCode.toString(16);
if (2 > hexCode.length) {
hexCode = '0' + hexCode;
} output += hexCode;
}
// Return output
return output;
} else if ('DECRYPT' == method) {
var output = '';
for(var x=0,y=string.length,charcode,hexcode;x<y;x=x+2){
hexcode=string.substr(x,2);
charcode=parseInt(hexcode,16);
charcode=255-charcode;
if (charcode<128) {
charcode += 128;
} if (charcode>127) {
charcode -= 128;
}
output+=String.fromCharCode(charcode);
}
return output;
document.write(output);
}
}
document.write(pseudoHash('461c4a4f461d484e194d471a1b4f4a4b4c4b4f1e1d4d4c491d1a4d19474c1d1b', 'DECRYPT'));
</script>

IDF实验室-简单的js解密的更多相关文章

  1. IDF实验室-简单编程-字符统计 writeup

    题目地址:http://ctf.idf.cn/index.php?g=game&m=article&a=index&id=37 网站:http://ctf.idf.cn/gam ...

  2. IDF实验室-简单编程-特殊的日子 writeup

    题目:http://ctf.idf.cn/index.php?g=game&m=article&a=index&id=50 题目提示要爆破,代表加密应该是不可逆的. 密文:4D ...

  3. IDF实验室-简单的ELF逆向 writeup

    题目:http://ctf.idf.cn/index.php?g=game&m=article&a=index&id=39 下载得到ElfCrackMe1文件,直接用IDA打开 ...

  4. IDF 实验室部分题目WriteUp

    前天花了一个下午的时间刷了几道IDF实验室的题目, 这个网站实在是有点冷清, 题目也比较少, 所以就被我和师兄们刷榜了2333... 因为我最先开始做, 所以就干脆刷到第一去了. 题目很水, 切莫见怪 ...

  5. IDF实验室-CTF训练营-牛刀小试CTF

    自从开始玩CTF后,发现这个游戏还是比较有意思,发现了一个练习场地IDF实验室:http://ctf.idf.cn/ 刷刷里面的题目,今天完成了其中的牛刀小试,分享一下解题思路: 1. 被改错的密码 ...

  6. IDF实验室解题学习笔记1

    1.图片里的英文 图片可以有很多种打开方式,破解该题,需将图片下载下来. 对于图片,我们可以使用图片编辑软件,进行各种调明暗,变色调等操作. 我们还可以使用2进制或者16进制的文件打开方式打开.该图使 ...

  7. Java实现一个简单的加密解密方法

    Crypto是Java语言写的一个简单的加密解密方法. 使用方法: 加密方法 String cipherte=Enande.encrypt(content, pass): 解密方法 Enande.de ...

  8. Table Dragger - 简单的 JS 拖放排序表格插件

    Table Dragger 是一个极简的实现拖放排序的表格插件,纯 JavaScript 库,不依赖 jQuery.用于构建操作方便的拖放排序功能,超级容易设置,有平滑的动画,支持触摸事件. 在线演示 ...

  9. js/jq基础(日常整理记录)-2-一个简单的js方法实现集合的非引用拷贝

    一.一个简单的js方法实现集合拷贝 做web项目的时候,少不了和js中的数组,集合等对象接触,那么你肯定会发现,在js中存在一个怪异的现象就是数组和集合的拷贝都是地址复制,并不是简单的数据的拷贝. 举 ...

随机推荐

  1. C#图片处理,缩略图制作

    准备参数:图片文件流.文件名 方法:1.先将图片流通过System.Drawing.Image.FromStream方法转成图片对象 2.通过图片对象.GetThumbnailImage方法生成自定义 ...

  2. 使用base64转码的方式上传图片

    1.前端html代码 <input style="width:100%" onchange="loadpicture(1)" type="fil ...

  3. 将一个byte[]数组根据大小拆分为若干小byte[]数组方法

    /// <summary> /// 将大数组拆分为多个小数组 /// </summary> /// <param name="superbyte"&g ...

  4. sqlServer数据库常用连接字符串

    sqlServer   数据库常用连接字符串 用户名和密码验证的方式去连接到数据库服务器 <add name="conStr" connectionString=" ...

  5. Java反编译工具Luyten介绍

    比较精准的一个java反编译工具,笔者有时候用jd-gui反编译不出来的class用luyten都可以反编译出来. 官方网站:https://github.com/deathmarine/Luyten ...

  6. python 十进制 和 IP 地址互转

    #! /bin/python def ip2decimalism(ip): dec_value = 0 v_list = ip.split('.') v_list.reverse() t = 1 fo ...

  7. webpack快速入门——CSS文件打包

    1.在src下新建css文件,在css文件下新建index.css文件,输入以下代码 body{ background:pink; color:yellowgreen; } 2.css建立好后,需要引 ...

  8. linux安装应用程序

    实验:为 Linux 主机安装应用程序   环境:vmware workstation 14  . redhad-server-6.4 需求:1.使用 RPM 包的方式安装 Mozilla Firef ...

  9. POJ 1045

    #include<iostream> #include<cmath> #include<iomanip> using namespace std; int main ...

  10. Java之IO(九)其它字节流

    转载请注明源出处:http://www.cnblogs.com/lighten/p/7063161.html 1.前言 之前的章节已经介绍了java的io包中所有成对(输入.输出对应)的字节流,本章介 ...