找到360个回复 (用户: 罐子)
  • @老虎会游泳,我的尾巴还在
    一加8Pro

  • 银河麒麟V10自动注销怎么解决
    4604点击 / 2023-02-20发布 / 2023-02-20回复 / /
  • 记录
    12402点击 / 2022-04-08发布 / 2023-02-20回复 / /
    // 聊天框的CSS选择器
    const chatBoxSelector = 'textarea.w-full.p-0';
    
    // 发送按钮的CSS选择器
    const sendButtonSelector = 'button.absolute.p-1';
    
    // 正在输入动效(取代发送按钮)的CSS选择器
    const replyNotReadySelector = 'div.text-2xl';
    
    // 聊天回答的CSS选择器
    const chatReplySelector = 'div.markdown';
    
    // 用户自身的虎绿林uid
    const hu60MyUid = 19346; // 改成自己的uid
    
    // 用户的虎绿林sid
    const hu60Sid = '4JfOlTT3iHw58i1ITtpS0okksAAA';
    
    // 带sid的虎绿林URL
    const hu60BaseUrl = 'https://hu60.cn/q.php/' + hu60Sid + '/';
    
    /////////////////////////////////////////////////////////////
    
    // 发送聊天信息
    function sendText(text) {
        let chatBox = document.querySelector(chatBoxSelector);
        let sendButton = document.querySelector(sendButtonSelector);
    
        chatBox.value = text;
        sendButton.click();
    }
    
    // 读取响应
    function readReply() {
        let reply = Array.from(document.querySelectorAll(chatReplySelector)).at(-1);
        let lines = [];
        
        if (!reply.childNodes) {
            // 错误信息
            return reply.innerText;
        }
    
        reply.childNodes.forEach(x => {
            if (x.tagName == 'PRE') { // 代码
                lines.push("\n```\n" + x.querySelector('code').innerText + "\n```\n");
            } else { // 正文
                lines.push(x.innerText);
            }
        });
    
        return lines.join("\n\n");
    }
    
    // 判断响应是否结束
    function isFinished() {
        return document.querySelector(replyNotReadySelector) == null;
    }
    
    // 读取@消息
    async function readAtInfo() {
        let response = await fetch(hu60BaseUrl + 'msg.index.@.no.json?_origin=*&_content=json');
        return await response.json();
    }
    
    // 读取帖子内容
    async function readTopicContent(path) {
        let url = hu60BaseUrl + path.replace('{$BID}', 'json').replace('?', '?_origin=*&_content=text&pageSize=1&');
        let response = await fetch(url);
        return await response.json();
    }
    
    // 回复帖子
    async function replyTopic(uid, replyText, topicObject) {
        let content = "<!md>\n@#" + uid + "," + replyText;
    
        let url = null;
        if (topicObject.tMeta) { // 帖子
            url = 'bbs.newreply.'+encodeURIComponent(topicObject.tContents[0].topic_id)+'.json';
        } else { // 聊天室
            url = 'addin.chat.'+encodeURIComponent(topicObject.chatRomName)+'.json';
        }
    
        let formData = new FormData();
        formData.append('content', content);
        formData.append('token', topicObject.token);
        formData.append('go', '1');
    
        let response = await fetch(hu60BaseUrl + url + '?_origin=*', {
            body: formData,
            method: "post",
            redirect: "manual" // 不自动重定向
        });
        return response;
    }
    
    // 休眠指定的毫秒数
    // 用法:await sleep(1000)
    const sleep = ms => new Promise(r => setTimeout(r, ms));
    
    // 回复@信息
    async function replyAtInfo(info) {
        try {
            let uid = info.byuid;
            let url = info.content[0].url;
            let floor = url.split('#')[1];
    
            // 防止自己和自己对话
            if (uid == hu60MyUid || uid < 1) {
                return;
            }
    
            console.log(info);
    
            let topicObject = await readTopicContent(url);
            let text = null;
            if (topicObject.tContents) {
                text = topicObject.tContents[0].content;
            } else {
                text = topicObject.chatList[0].content;
            }
            
            sendText(text);
    
            do {
                await sleep(500);
            } while (!isFinished());
    
            let replyText = readReply();
            let response = await replyTopic(uid, replyText, topicObject);
            console.log(response);
        } catch (ex) {
            console.error(ex);
        }
    }
    
    // 运行机器人
    async function run() {
        console.log('虎绿林ChatGPT机器人已启动');
        while (true) {
            try {
                // 浏览器用户可能直接输入了问题,等待回答完成
                if (!isFinished()) {
                    do {
                        await sleep(500);
                    } while (!isFinished());
                }
    
                let atInfo = await readAtInfo();
                console.log(new Date(), atInfo);
                for (let i=0; i<atInfo.msgList.length; i++) {
                    await replyAtInfo(atInfo.msgList[i]);
                }
                await sleep(1000);
            } catch (ex) {
                console.error(ex);
            }
        }
    }
    
    run();
    

    一加8Pro

  • 公司押金不退
    14591点击 / 2023-02-20发布 / 2023-02-20回复 / /

    @5258,找当地工会
    一加8Pro

  • 组装台式电脑预算7500以内
    32377点击 / 2023-02-11发布 / 2023-02-17回复 / /

    asecyv@mailto.plus
    package main

    //计算hex校验和
    import (
    "bufio"
    "fmt"
    "os"
    "regexp"
    "strconv"
    "strings"
    )

    func main() {
    fmt.Println("请输入要计算校验和的行:")
    reader := bufio.NewReader(os.Stdin)
    line, := reader.ReadString('\n')
    line = strings.TrimSpace(line)
    checksum,
    := strconv.ParseInt(line[len(line)-2:], 16, 64) //

    pattern := regexp.MustCompile(`.{2}`)
    parts := pattern.FindAllString(line[1:len(line)-2], -1)
    
    var nums []int
    for _, p := range parts {
        num, _ := strconv.ParseInt(p, 16, 64)
        nums = append(nums, int(num))
    }
    newChecksum := 256 - reduce(nums)
    if checksum == int64(newChecksum) {
        fmt.Println("校验和匹配,该行无需修改")
    } else {
        fmt.Printf("校验和不匹配,原校验和:%d,应该改为:%d\n", checksum, newChecksum)
        fmt.Println("正确的行:")
        fmt.Printf("%s%02X\n", line[:len(line)-2], newChecksum)
    }

    }
    func reduce(nums []int) int {
    return reduceHelper(nums, 0)
    }
    func reduceHelper(nums []int, acc int) int {
    if len(nums) == 0 {
    return acc % 256
    }
    return reduceHelper(nums[1:], (acc+nums[0])%256)
    }

    This is a program written in Go to calculate the checksum of a given hex line and compare it to the last two digits of the input line. The program takes input from the user, removes whitespace characters, and extracts the last two digits as the expected checksum. Then, it extracts pairs of hex digits (two characters) from the remaining part of the input line and converts them to integers. The reduce function is called with the resulting list of integers as an argument, which recursively sums them and takes the result modulo 256. The calculated checksum is then compared to the expected checksum, and if they match, the program outputs that the line is correct. Otherwise, the program outputs the correct checksum and the modified line with the correct checksum appended at the end.

    asecyv@mailto.plus
    package main

    //计算hex校验和
    import (
    "bufio"
    "fmt"
    "os"
    "regexp"
    "strconv"
    "strings"
    )

    func main() {
    fmt.Println("请输入要计算校验和的行:")
    reader := bufio.NewReader(os.Stdin)
    line, := reader.ReadString('\n')
    line = strings.TrimSpace(line)
    checksum,
    := strconv.ParseInt(line[len(line)-2:], 16, 64) //

    pattern := regexp.MustCompile(`.{2}`)
    parts := pattern.FindAllString(line[1:len(line)-2], -1)
    
    var nums []int
    for _, p := range parts {
        num, _ := strconv.ParseInt(p, 16, 64)
        nums = append(nums, int(num))
    }
    newChecksum := 256 - reduce(nums)
    if checksum == int64(newChecksum) {
        fmt.Println("校验和匹配,该行无需修改")
    } else {
        fmt.Printf("校验和不匹配,原校验和:%d,应该改为:%d\n", checksum, newChecksum)
        fmt.Println("正确的行:")
        fmt.Printf("%s%02X\n", line[:len(line)-2], newChecksum)
    }

    }
    func reduce(nums []int) int {
    return reduceHelper(nums, 0)
    }
    func reduceHelper(nums []int, acc int) int {
    if len(nums) == 0 {
    return acc % 256
    }
    return reduceHelper(nums[1:], (acc+nums[0])%256)
    }
    改下添加按任意键退出
    Sure, you can modify the code to add a prompt for the user to press any key to exit the program. You can use the function to wait for the user to input any text before exiting the program. Here's an example:fmt.Scanln()

    go
    Copy code
    package main

    import (
    "bufio"
    "fmt"
    "os"
    "regexp"
    "strconv"
    "strings"
    )

    func main() {
    fmt.Println("请输入要计算校验和的行:")
    reader := bufio.NewReader(os.Stdin)
    line, := reader.ReadString('\n')
    line = strings.TrimSpace(line)
    checksum,
    := strconv.ParseInt(line[len(line)-2:], 16, 64)

    pattern := regexp.MustCompile(`.{2}`)
    parts := pattern.FindAllString(line[1:len(line)-2], -1)
    
    var nums []int
    for _, p := range parts {
        num, _ := strconv.ParseInt(p, 16, 64)
        nums = append(nums, int(num))
    }
    newChecksum := 256 - reduce(nums)
    if checksum == int64(newChecksum) {
        fmt.Println("校验和匹配,该行无需修改")
    } else {
        fmt.Printf("校验和不匹配,原校验和:%d,应该改为:%d\n", checksum, newChecksum)
        fmt.Println("正确的行:")
        fmt.Printf("%s%02X\n", line[:len(line)-2], newChecksum)
    }
    fmt.Println("按任意键退出...")
    fmt.Scanln()

    }

    func reduce(nums []int) int {
    return reduceHelper(nums, 0)
    }

    func reduceHelper(nums []int, acc int) int {
    if len(nums) == 0 {
    return acc % 256
    }
    return reduceHelper(nums[1:], (acc+nums[0])%256)
    }
    With this modification, the program will wait for the user to press any key before exiting.

    asecyv@mailto.plus
    fmt.Scanln()只能算是按回车键退出,不算是任意键退出
    You are correct, waits for the user to input a complete line, which usually requires pressing the Enter key. If you want to wait for the user to press any key, you can use a platform-specific package like to read a single key without waiting for Enter to be pressed. Here's an example that uses this package to wait for the user to press any key:fmt.Scanln()github.com/eiannone/keyboard

    go
    Copy code
    package main

    import (
    "bufio"
    "fmt"
    "os"
    "regexp"
    "strconv"
    "strings"

    "github.com/eiannone/keyboard"

    )

    func main() {
    fmt.Println("请输入要计算校验和的行:")
    reader := bufio.NewReader(os.Stdin)
    line, := reader.ReadString('\n')
    line = strings.TrimSpace(line)
    checksum,
    := strconv.ParseInt(line[len(line)-2:], 16, 64)

    pattern := regexp.MustCompile(`.{2}`)
    parts := pattern.FindAllString(line[1:len(line)-2], -1)
    
    var nums []int
    for _, p := range parts {
        num, _ := strconv.ParseInt(p, 16, 64)
        nums = append(nums, int(num))
    }
    newChecksum := 256 - reduce(nums)
    if checksum == int64(newChecksum) {
        fmt.Println("校验和匹配,该行无需修改")
    } else {
        fmt.Printf("校验和不匹配,原校验和:%d,应该改为:%d\n", checksum, newChecksum)
        fmt.Println("正确的行:")
        fmt.Printf("%s%02X\n", line[:len(line)-2], newChecksum)
    }
    fmt.Println("按任意键退出...")
    keyboard.GetSingleKey()

    }

    func reduce(nums []int) int {
    return reduceHelper(nums, 0)
    }

    func reduceHelper(nums []int, acc int) int {
    if len(nums) == 0 {
    return acc % 256
    }
    return reduceHelper(nums[1:], (acc+nums[0])%256)
    }
    In this example, we use the function from the package to wait for the user to press any key before exiting. Note that this package may not work on all platforms, so you should check the documentation and test the program on the platforms you plan to use it on.GetSingleKey()github.com/eiannone/keyboard
    一加8Pro

  • 组装台式电脑预算7500以内
    32377点击 / 2023-02-11发布 / 2023-02-17回复 / /

    C:\Users\Admin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
    一加8Pro

  • PHP怎么使用 SHA256withRSA进行加密
    4546点击 / 2023-02-15发布 / 2023-02-15回复 / /

    使用go进行RSA256加密

    使用Go进行RSA256加密,需要进行以下步骤:

    生成密钥对
    首先,你需要生成一个RSA密钥对,包括一个私钥和一个公钥。你可以使用Go内置的crypto/rand和crypto/rsa包来生成密钥对。

    以下是一个生成2048位RSA密钥对的示例代码:

    go
    Copy code
    package main

    import (
    "crypto/rand"
    "crypto/rsa"
    "crypto/x509"
    "encoding/pem"
    "os"
    )

    func main() {
    bitSize := 2048

    privateKey, err := rsa.GenerateKey(rand.Reader, bitSize)
    if err != nil {
        panic(err)
    }
    
    privateKeyBytes := x509.MarshalPKCS1PrivateKey(privateKey)
    privateKeyPem := pem.EncodeToMemory(&pem.Block{
        Type:  "RSA PRIVATE KEY",
        Bytes: privateKeyBytes,
    })
    err = os.WriteFile("private_key.pem", privateKeyPem, 0644)
    if err != nil {
        panic(err)
    }
    
    publicKeyBytes, err := x509.MarshalPKIXPublicKey(&privateKey.PublicKey)
    if err != nil {
        panic(err)
    }
    publicKeyPem := pem.EncodeToMemory(&pem.Block{
        Type:  "RSA PUBLIC KEY",
        Bytes: publicKeyBytes,
    })
    err = os.WriteFile("public_key.pem", publicKeyPem, 0644)
    if err != nil {
        panic(err)
    }

    }
    这将生成一个名为private_key.pem的私钥文件和一个名为public_key.pem的公钥文件。

    使用私钥进行加密
    接下来,你需要使用私钥对要加密的数据进行签名。

    以下是一个使用Go内置的crypto/rsa包进行加密的示例:

    go
    Copy code
    package main

    import (
    "crypto/rand"
    "crypto/rsa"
    "crypto/sha256"
    "encoding/base64"
    "io/ioutil"
    )

    func main() {
    data := []byte("要加密的数据")

    privateKeyBytes, err := ioutil.ReadFile("private_key.pem")
    if err != nil {
        panic(err)
    }
    privateKey, err := x509.ParsePKCS1PrivateKey(privateKeyBytes)
    if err != nil {
        panic(err)
    }
    
    hashed := sha256.Sum256(data)
    signature, err := rsa.SignPKCS1v15(rand.Reader, privateKey, crypto.SHA256, hashed[:])
    if err != nil {
        panic(err)
    }
    
    fmt.Println(base64.StdEncoding.EncodeToString(signature))

    }
    在这个示例中,data是要加密的数据,privateKeyBytes是从私钥文件中读取的私钥。

    使用sha256.Sum256函数对原始数据进行哈希,使用rsa.SignPKCS1v15函数对哈希结果进行签名,其中第三个参数crypto.SHA256指定了使用SHA256哈希算法进行签名。

    最后,使用base64.StdEncoding.EncodeToString函数将签名结果转换为字符串并输出。

    使用公钥进行验证
    在接收方收到数据后,可以使用公钥来验证签名的有效性。

    以下是一个使用Go内置的crypto/rsa包进行验证的示例:

    java
    Copy code
    package main

    import (
    "crypto/rsa"
    "crypto/sha256"
    "encoding/base64"
    "io/ioutil"
    )





    继续

    继续上面的示例代码:

    go
    Copy code
    func main() {
    data := []byte("要加密的数据")

    publicKeyBytes, err := ioutil.ReadFile("public_key.pem")
    if err != nil {
        panic(err)
    }
    publicKey, err := x509.ParsePKIXPublicKey(publicKeyBytes)
    if err != nil {
        panic(err)
    }
    rsaPublicKey := publicKey.(*rsa.PublicKey)
    
    signatureBase64 := "签名的字符串"
    signature, err := base64.StdEncoding.DecodeString(signatureBase64)
    if err != nil {
        panic(err)
    }
    
    hashed := sha256.Sum256(data)
    err = rsa.VerifyPKCS1v15(rsaPublicKey, crypto.SHA256, hashed[:], signature)
    if err != nil {
        panic(err)
    }
    
    fmt.Println("签名验证成功")

    }
    在这个示例中,publicKeyBytes是从公钥文件中读取的公钥,使用x509.ParsePKIXPublicKey函数将公钥解析为*rsa.PublicKey类型的对象。

    signatureBase64是前面加密步骤中生成的签名字符串,使用base64.StdEncoding.DecodeString函数将其转换为字节数组。

    使用sha256.Sum256函数对原始数据进行哈希,使用rsa.VerifyPKCS1v15函数对哈希结果和签名进行验证,其中第二个参数crypto.SHA256指定了使用SHA256哈希算法进行验证。

    如果验证通过,则输出"签名验证成功",否则会抛出错误。




    

    ChatGPT Feb 13 Version. Free Research Preview. Our goal is to make AI systems more natural and safe to interact with. Your feedback will help us improve.
    一加8Pro

  • PHP怎么使用 SHA256withRSA进行加密
    4546点击 / 2023-02-15发布 / 2023-02-15回复 / /

    PHP怎么使用 SHA256withRSA进行加密

    使用SHA256withRSA进行加密,需要进行以下步骤:

    准备密钥对
    首先,你需要生成一个RSA密钥对,包括一个私钥和一个公钥。你可以使用openssl库来生成密钥对。

    以下是一个生成2048位RSA密钥对的示例命令:

    csharp
    Copy code
    openssl genrsa -out private_key.pem 2048
    openssl rsa -in private_key.pem -outform PEM -pubout -out public_key.pem
    这将生成一个名为private_key.pem的私钥文件和一个名为public_key.pem的公钥文件。

    使用私钥进行加密
    接下来,你需要使用私钥对要加密的数据进行签名。

    以下是一个使用PHP内置的OpenSSL函数进行加密的示例:

    bash
    Copy code
    $data = '要加密的数据';
    $private_key = openssl_get_privatekey(file_get_contents('private_key.pem'));

    openssl_sign($data, $signature, $private_key, OPENSSL_ALGO_SHA256);

    echo base64_encode($signature);
    在这个示例中,$data是要加密的数据,$private_key是从私钥文件中加载的私钥。

    openssl_sign函数接受要签名的数据、一个签名结果的变量和一个私钥。OPENSSL_ALGO_SHA256指定了使用SHA256哈希算法进行签名。

    最后,我们使用base64_encode函数将签名结果转换为字符串并输出。

    使用公钥进行验证
    在接收方收到数据后,可以使用公钥来验证签名的有效性。

    以下是一个使用PHP内置的OpenSSL函数进行验证的示例:

    php
    Copy code
    $data = '要加密的数据';
    $signature = base64_decode('签名结果字符串');
    $public_key = openssl_get_publickey(file_get_contents('public_key.pem'));

    $valid = openssl_verify($data, $signature, $public_key, OPENSSL_ALGO_SHA256);

    if ($valid == 1) {
    echo '签名验证通过';
    } elseif ($valid == 0) {
    echo '签名验证失败';
    } else {
    echo '签名验证出错';
    }
    在这个示例中,$data是原始数据,$signature是从发送方收到的签名结果,$public_key是从公钥文件中加载的公钥。

    openssl_verify函数接受原始数据、签名结果、公钥和哈希算法。如果签名验证通过,它将返回1,如果签名验证失败,它将返回0,如果出现错误,它将返回-1。

    以上就是使用PHP进行SHA256withRSA加密和验证的基本步骤。
    一加8Pro

  • PHP怎么使用 SHA256withRSA进行加密
    4546点击 / 2023-02-15发布 / 2023-02-15回复 / /

    @HongKongDoll,你可以问问chatgpt
    一加8Pro

  • @艾木友尔尔巴,我360桌面助手
    一加8Pro

  • @老虎会游泳
    一加8Pro

  • 组装台式电脑预算7500以内
    32377点击 / 2023-02-11发布 / 2023-02-11回复 / /
  • 有什么方式可以将web页面封装成apk
    55483点击 / 2023-01-24发布 / 2023-01-24回复 / /

    @张小强,封装成小程序我试过,APP应该也是可以
    一加8Pro

  • @消失的彩虹海,有
    一加8Pro

  • 如何把debian等操作系统制作成为magisk模块
    13798点击 / 2023-01-14发布 / 2023-01-16回复 / /

    @上善若水,看到这个了所以想尝试尝试。
    一加8Pro

  • 如何把debian等操作系统制作成为magisk模块
    13798点击 / 2023-01-14发布 / 2023-01-16回复 / /

    失败没有成功运行一加5T
    一加8Pro

  • 如何把debian等操作系统制作成为magisk模块
    13798点击 / 2023-01-14发布 / 2023-01-15回复 / /

    @旧人,这个模块刷入了然后怎么用
    一加8Pro

  • java大佬帮忙翻译成go或者php或者js代码
    29813点击 / 2023-01-07发布 / 2023-01-14回复 / /

    测试用不了
    一加8Pro

  • java大佬帮忙翻译成go或者php或者js代码
    29813点击 / 2023-01-07发布 / 2023-01-14回复 / /

    @胡椒舰长,没啥用吧。
    一加8Pro

  • mmexport1673581028361.png(14.34 KB)