Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Phương thức crypto.getCurves() trong Node.js

Mô tả

Phương thức crypto.getCurves() sẽ trả về một mảng chứa tên của tất cả các đường cong elliptic (elliptic curves) được hỗ trợ. Gói crypto có một danh sách lớn các đường cong elliptic có thể dùng để tạo đối tượng trao đổi khóa Elliptic Curve Diffie-Hellman (ECDH).

Cú pháp

crypto.getCurves()

Tham số

Vì nó trả về danh sách tất cả đường cong elliptic. Nó không cần bất kỳ đối số nào.

Ví dụ

Tạo file tên curves.js và sao chép đoạn mã dưới. Sau khi tạo file, dùng lệnh sau để chạy:

node curves.js

curves.js

// A node demo program for getting all elliptic curves // Importing the crypto module const crypto = require('crypto'); // Calling the getCurves() method const curves = crypto.getCurves(); // Printing the list of all the algorithms there is console.log("The list of all elliptic curves are as follows: ", curves);

Đầu ra

C:\home\node>> node curves.js The list of all elliptic curves are as follows: [ 'Oakley-EC2N-3', 'Oakley-EC2N-4', 'SM2', 'brainpoolP160r1', 'brainpoolP160t1', 'brainpoolP192r1', 'brainpoolP192t1', 'brainpoolP224r1', 'brainpoolP224t1', 'brainpoolP256r1', 'brainpoolP256t1', 'brainpoolP320r1', 'brainpoolP320t1', 'brainpoolP384r1', 'brainpoolP384t1', 'brainpoolP512r1', 'brainpoolP512t1', 'c2pnb163v1', 'c2pnb163v2', 'c2pnb163v3', 'c2pnb176v1', 'c2pnb208w1', 'c2pnb272w1', 'c2pnb304w1', 'c2pnb368w1', 'c2tnb191v1', 'c2tnb191v2', 'c2tnb191v3', 'c2tnb239v1', 'c2tnb239v2', 'c2tnb239v3', 'c2tnb359v1', 'c2tnb431r1', 'prime192v1', 'prime192v2', 'prime192v3', 'prime239v1', 'prime239v2', 'prime239v3', 'prime256v1', 'secp112r1', 'secp112r2', 'secp128r1', 'secp128r2', 'secp160k1', 'secp160r1', 'secp160r2', 'secp192k1', 'secp224k1', 'secp224r1', 'secp256k1', 'secp384r1', 'secp521r1', 'sect113r1', 'sect113r2', 'sect131r1', 'sect131r2', 'sect163k1', 'sect163r1', 'sect163r2', 'sect193r1', 'sect193r2', 'sect233k1', 'sect233r1', 'sect239k1', 'sect283k1', 'sect283r1', 'sect409k1', 'sect409r1', 'sect571k1', 'sect571r1', 'wap-wsg-idm-ecid-wtls1', 'wap-wsg-idm-ecid-wtls10', 'wap-wsg-idm-ecid-wtls11', 'wap-wsg-idm-ecid-wtls12', 'wap-wsg-idm-ecid-wtls3', 'wap-wsg-idm-ecid-wtls4', 'wap-wsg-idm-ecid-wtls5', 'wap-wsg-idm-ecid-wtls6', 'wap-wsg-idm-ecid-wtls7', 'wap-wsg-idm-ecid-wtls8', 'wap-wsg-idm-ecid-wtls9' ]