CNode

光棍节程序员闯关秀.. 第 9 题用纯 JS 有办法做不?

Jjiyinyiyong发布于14 年前最后回复14 年前6 回复7502 浏览0 收藏

... 链接是攻略.. 想玩游戏的话先别点,,, 第九关的数字, 攻略上讲了但是用来不同的软件... 没劲..用代码请问怎么写的?

数据 Gist 好了, Markdown 影响性能, https://gist.github.com/4054140

查看回复

回复 (6)

A
a272121742#1·14 年前

有意思

A
a272121742#2·14 年前
H
hades#3·14 年前

脱光好久了不玩哈哈。

J
jiyinyiyong#4·14 年前

ASIIC 编码转 Base64.. 问了同学原理然后搞定了.. tar 包解压的那一步.. 不知道 Node 怎么用, 只好调用了 Bash 命令 代码是 LiveScript

require! \fs
require! \buffer
require! \path
{exec} = require \child_process

show = console.log 

fs.read-file \string.txt \utf8 (err, file) ->
  throw err if err?
  string = file.replace(/\_/g, '1').replace(/\n/g, ' ')
  arr = string.split ' '

  res = arr
    .map -> parse-int it, 2
    .map -> String.from-char-code it
    .join ''

  b = new Buffer res, \base64

  fs.write-file \a.tgz b, ->
    exec "/bin/tar zxvf a.tgz" (err, stdout, stder) ->
      # show arguments
      arg = path.join __dirname, \./cang.jpg
      exec "google-chrome #arg"
J
jiyinyiyong#5·14 年前

现在能从代码里写出 .tar 包了.. 求指点怎么用 Node 解开 .tar.. 另外解压出来有两个问题, 其中一个是隐藏文件,,, 里面是什么?

require! \fs
require! \buffer
require! \path
require! \zlib
{exec} = require \child_process

show = console.log 

fs.read-file \string.txt \utf8 (err, file) ->
  # throw err if err?
  res = file
    .replace /\_/g, '1'
    .replace /\n/g, ' '
    .split ' '
    .map -> parse-int it, 2
    .map -> String.from-char-code it
    .join ''

  b = new Buffer res, \base64

  zlib.gunzip b, (err, data) ->
    fs.write-file \c.tar data
S
stonelee#6·14 年前

Chrome控制台解法:

$('pre').innerHTML.replace(/_/g,1).split(/\s/).map(function(i){return String.fromCharCode(parseInt(i,2))}).join('');

得到base64字符串

参与回复
登录后即可参与回复。登录