<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] ### crypto 加密實例代碼 ``` "use strict"; //引用crypto模塊 const crypto = require("crypto"); //-------------MD5 可以任意多次調用update(),update()默認字符串編碼是UTF-8 const hash = crypto.createHash("md5"); hash.update("hello, world!"); console.log(hash.digest("hex")); //--------------SHA1 const sha1 = crypto.createHash("sha1"); sha1.update("hello,world!"); console.log(sha1.digest("hex")); //-------------SHA256 const sha256 = crypto.createHash("sha256"); sha256.update("hello,world!"); console.log(sha256.digest("hex")); //------------SHA512 const sha512 = crypto.createHash("sha512"); sha512.update("hello,world!"); console.log(sha512.digest("hex")); //------------Hmac const hmac = crypto.createHash("sha256","secret-key"); hmac.update("hello world!"); console.log(hmac.digest("hex")); //-----------AES function aesEncrypt(data, key) { const cipher = crypto.createCipher("aes192", key); var crypted = cipher.update(data, "utf8", "hex"); crypted += cipher.final("hex"); return crypted; } function aesDecrypt(encrypted, key) { const decipher = crypto.createDecipher("aes192", key); var decrypted = decipher.update(encrypted, "hex", "utf8"); decrypted += decipher.final("utf8"); return decrypted; } var data = "hello this a secret message!"; var key = "password"; var encrypted = aesEncrypt(data,key); var decrypted = aesDecrypt(encrypted, key); console.log("plain text:" + data); console.log("Encrypted text:" +encrypted); console.log(("Decrypted text:" + decrypted)); //------------------diffie-hellman var ming = crypto.createDiffieHellman(512); var ming_keys = ming.generateKeys(); var prime = ming.getPrime(); var generator = ming.getGenerator(); console.log("Prime:" + prime.toString("hex")); console.log("Generator:" + generator.toString("hex") ); var hong = crypto.createDiffieHellman(prime, generator); var hong_keys = hong.generateKeys(); var ming_secret = ming.computeSecret(hong_keys); var hong_secret = hong.computeSecret(ming_keys); console.log("Secret of xiao ming:" + ming_secret.toString("hex")); console.log("Secret of xiao hong:" + hong_secret.toString("hex")); //----------RSA const fs = require("fs"); //從文件加載key function loadKey(file) { return fs.readFileSync(file,"utf8"); }; let prvKey = loadKey("./rsa-prv.pem"); let pubKey = loadKey("./rsa-pub.pem"); let message = "hello world!"; //使用私鑰加密公鑰解密 let enc_by_prv = crypto.privateEncrypt(prvKey,Buffer.from(message,"utf8")); console.log("encrypted by private key:" + enc_by_prv.toString("hex")); let dec_by_pub = crypto.publicDecrypt(pubKey, enc_by_prv); console.log("decrypted by public key:" + dec_by_pub.toString("utf8")); //使用公鑰進行加密私鑰解密 let enc_by_pub = crypto.publicEncrypt(pubKey,Buffer.from(message,"utf8")); console.log("encrypted by public key:" + enc_by_pub.toString("hex")); let dec_by_prv = crypto.privateDecrypt(prvKey,enc_by_pub); console.log("decrypted by private key:" + dec_by_prv.toString("utf8")); ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看