捏脸游戏是如何使用png来隐藏信息的
虽然有点好奇, 但基本上还是有点头绪的, 之前用png来隐藏视频文件, 通过压缩的方式隐藏
不知道有没有修好
1, 图片压缩很重要, 不只是为了减少存储大小, 而且是为了向这种方式进行隐秘的信息存储
2, 简单的信息使用这种方式隐藏很方便, 不必使用zip或者两个文件分别维护, 甚至可以加入秘钥等身份鉴别信息
在下面的图片中, 添加隐藏信息, 诸如名字, 身高等
png文件结构
字符串和的一些操作
const s = "12345678";
const c = "45";
const i = s.indexOf(c);
console.log(i);
console.log(s.slice(0, i + c.length));
console.log(s.slice(i + c.length));console.log(Buffer.from("HoneySelectCharaFemale").toString("hex").toLowerCase()
);const h2 ="3247dc7e889f3775a08e6d23c9404b8e82694e17ef9b27868aef8c61e284279e077d0200000000000903000000000000";
console.log(Buffer.from(h2, "hex").toString('utf8'));
简单来讲就是读图片, 转换为hex格式, 然后从png尾部分割为png和txt两端, 重新写到两个文件中,完成图片和信息的分离
const fs = require("fs");
const str = fs.readFileSync("./hs/t.png");
const hex = str.toString("hex");
fs.writeFileSync("./h.txt", hex);
const end = "AE 42 60 82".replace(/\s+/gis, "").toLowerCase();
console.log("end", end, hex.includes(end));
if (hex.includes(end)) {const i = hex.indexOf(end);const png = hex.slice(0, i + end.length);const text = hex.slice(i + end.length);console.log("png", png.length);console.log("text", text.length);const txtBuffer = Buffer.from(text, "hex");console.log(txtBuffer.toString('utf8'))fs.writeFileSync("./text.txt", txtBuffer, "utf8");const pngBuffer = Buffer.from(png, "hex");fs.writeFileSync("./png.png", pngBuffer);
}
成功分离后图片没有损坏, 不过数据不知道什么格式, 只能读一部分
这个应该是标示自定义数据的开头, 后面就是附加的隐藏数据了