站点正在导入数据,暂时处于只读模式:这段时间里无法登录,也不能发帖或回复。

自用——加密私信

inferior北大未名
//openpgpjs github上的文档居然落后于自己的版本了。。。真是蛋疼

fetch("https://cdnjs.cloudflare.com/ajax/libs/openpgp/4.10.10/openpgp.min.js")
      .then(response => response.text())
      .then(data => {
        eval(data)
      })

var _username
if (window.location.toString().match("target")!=null){
//https://2047.name/editor?target=username/????
const splitAt = 4
_username=window.location.toString().split("/")[splitAt]}
else{
//https://2047.name/m/ABCDEF123456
//和 ??? 之间的私信对话 
_username=document.getElementsByClassName("header_title")[0].innerText.slice(2).split(" ")[0]
}


var _pubKey
fetch("https://2047.name/public_key/"+_username)
      .then(response => response.text())
      .then(data => {
        _pubKey=data
      })
const _encryptButton=document.createElement("button")
_encryptButton.innerText="加密"
const _previewButton=document.getElementById("editor_btnpreview")
_previewButton.insertAdjacentElement("afterend",_encryptButton)
const _textArea=document.getElementById("editor_text")

_encryptButton.onclick= async () =>{
if (_pubKey[1]=="<"){throw "No PubKey!" }
const _textContent=_textArea.value
const  _encryptedMessage = await openpgp.encrypt({
        message: openpgp.message.fromText(_textContent),         
        publicKeys: (await openpgp.key.readArmored(_pubKey)).keys, 
    });
_textArea.value=_encryptedMessage.data
}

1
  1. inferior北大未名
    inferior

    ttttttttttttttttttttttttttttttttttttttttt

  2. inferior北大未名
    inferior

    始终不敢把PGP私钥存在自己日常用的电脑上,也不敢放到云端,这样登陆的时候要搞很多步骤,非常麻烦。

    计划写个脚本用隐写术把私钥放到图片中,同时自动帮忙签名。随便一张图片应该不会引起怀疑。用不到其它功能电脑上也不用装PGP的软件了,风险更小。

    这周末必须把坑填了。

    2
  3. inferior北大未名
    inferior

    搞了块x86的板子专门用来在几个“友站”键政,靠iptables把除了前置代理的网络连接都禁用了,应该比较靠谱了吧。。

    一开始图便宜买的arm板子,买回来发现好多软件没有对应架构的软件包 蛋疼啊。。

  4. inferior北大未名
    inferior
    function _delAllPost()  {
    var postList = []
    
    Array.from(document.getElementsByClassName("date")).forEach((item) => {
        postList.push(item.href.split("p/")[1])
    
    })
    postList.forEach( async (item) => {
        if (!(isNaN(item))) {
            await api({
                action: 'mark_delete',
                target: "post/" + item.toString(),
            })
        }
    })
    }
    
    
  5. thphd
    thphd2047前站长
  6. thphd
    thphd2047前站长

    题外话,是不是应该有什么浏览器插件之类的可以hold住private key,不然解密就得弄到命令行去做。

  7. inferior北大未名
    inferior
    
    function _deluserPost(name) {
        var postList = []
    
        Array.from(document.getElementsByClassName("details")).forEach((item) => {
                postList.push({
                        post: item.children[4].dataset.id.split("/")[1],
                        username: item.children[0].innerText})
    
    
                }) 
    postList.forEach(async (item) => {
                if (item[username] == name) {
                    await api({
                        action: 'mark_delete',
                        target: "post/" + item[post].toString(),
                    })
                }
            })
        }
    
    
  8. inferior北大未名
    inferior

    @thphd <#131074>

    解密的部分周末忙别的事情去了又没写orz。。。我想法是搞个AES对称加密,加密后隐写术放到图片上,图片上传到一个只有你自己知道的地方,或者干脆放本地,当桌面背景也未尝不可,用的时候当参数传进去。猜网址+AES对称密钥+PGP本身的密码,强度对正常人应该足够了吧。。

    对安全要求没那么高的,或者设备本身可以信任的,存在本地txt文件直接读就行了吧。