কম্পিউটার

Node.js-এ crypto.createECDH() পদ্ধতি


crypto.createECDH() একটি উপবৃত্তাকার বক্ররেখা তৈরি করতে ব্যবহৃত হয় যা উপবৃত্তাকার বক্ররেখা ডিফি-হেলম্যান অর্থাৎ ECDH নামে পরিচিত যা ইনপুট প্যারামিটার বক্রনাম দ্বারা পূর্বনির্ধারিত একটি বক্ররেখা ব্যবহার করে। আপনি সমস্ত উপলব্ধ কার্ভ নামের তালিকা পেতে crypto.getCurves ব্যবহার করতে পারেন। এই পদ্ধতিটি 'ক্রিপ্টো' মডিউলের অংশ।

সিনট্যাক্স

crypto.createECDH(curveName)

পরামিতি

উপরের পরামিতিগুলি নীচে বর্ণনা করা হয়েছে

  • বক্রনাম - এটি কার্ভ নামের জন্য ইনপুট নেয়। এই বক্রনামটি ECDH তৈরির জন্য পূর্বনির্ধারিত বক্ররেখা নির্ধারণ করবে।

উদাহরণ

নামের সাথে একটি ফাইল তৈরি করুন - ECDH.js তৈরি করুন এবং নীচের কোড স্নিপেটটি অনুলিপি করুন। ফাইল তৈরি করার পরে, নীচের উদাহরণে দেখানো এই কোডটি চালানোর জন্য নিম্নলিখিত কমান্ডটি ব্যবহার করুন −

node createECDH.js

createECDH.js

// A node demo program for creating the ECDH

// Importing the crypto module
const crypto = require('crypto');

// Calling the getCiphers() method
const curve = crypto.createECDH('secp521r1');

// Printing the curve keys...
console.log(curve.generateKeys());

আউটপুট

C:\home\node>> node createECDH.js
<Buffer 04 00 be c4 3b eb cc ea 33 84 31 b0 7d 8b 9f e6 5b e0 6e 3a 40 21 49
f0 20 9f 92 33 cf 32 d7 a7 f1 df 90 82 9b fe 8f 7b 98 5b 7d 1a ee c6 ae b1 bd
1a ... >

উদাহরণ

আসুন আরও একটি উদাহরণ দেখি।

// A node demo program for creating the ECDH

// Importing the crypto module
const crypto = require('crypto');

// Calling the getCiphers() method
const curve = crypto.createECDH('secp521r1');
curve.generateKeys();

// Printing public & private curve keys...
console.log("Public Key: ", curve.getPublicKey());
console.log("Private Kye: ", curve.getPrivateKey());

আউটপুট

C:\home\node>> node cipherUpdate.js
Public Key: <Buffer 04 01 10 f7 fb d9 d7 f9 70 ba 6e 59 42 77 b6 1b 28 21 f1
3f ac 43 28 72 c6 33 b5 89 d3 77 6e 5a ea 8a 8a a1 27 a7 ab f1 b1 ea 41 ac dc
c5 09 83 01 48 ... >
Private Kye: <Buffer 01 d8 c4 d9 df 5c c8 54 e2 1f 82 94 ba 9c cd bc 88 3a e5
88 aa bd c8 2b 5c e9 f4 59 81 0b ae 18 f4 bf 21 43 56 74 55 d8 1d e6 b8 5f d8
e7 e2 52 ad 03 ... >

  1. Node.js-এ crypto.publicDecrypt() পদ্ধতি

  2. Node.js-এ crypto.privateEncrypt() পদ্ধতি

  3. Node.js-এ crypto.privateDecrypt() পদ্ধতি

  4. Node.js-এ crypto.getHashes() পদ্ধতি