GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: add example using algorithms not directly exposed · nodejs/node@440d117

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • crypto.markdown
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/crypto.markdown‎

Copy file name to clipboardExpand all lines: doc/api/crypto.markdown
+22Lines changed: 22 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,28 @@ console.log(sign.sign(private_key, 'hex'));
719719
// Prints the calculated signature
720720
```
721721

722+
A [`sign`][] instance can also be created by just passing in the digest
723+
algorithm name, in which case OpenSSL will infer the full signature algorithm
724+
from the type of the PEM-formatted private key, including algorithms that
725+
do not have directly exposed name constants, e.g. 'ecdsa-with-SHA256'.
726+
727+
Example: signing using ECDSA with SHA256
728+
729+
```js
730+
const crypto = require('crypto');
731+
const sign = crypto.createSign('sha256');
732+
733+
sign.update('some data to sign');
734+
735+
const private_key = '-----BEGIN EC PRIVATE KEY-----\n' +
736+
'MHcCAQEEIF+jnWY1D5kbVYDNvxxo/Y+ku2uJPDwS0r/VuPZQrjjVoAoGCCqGSM49\n' +
737+
'AwEHoUQDQgAEurOxfSxmqIRYzJVagdZfMMSjRNNhB8i3mXyIMq704m2m52FdfKZ2\n' +
738+
'pQhByd5eyj3lgZ7m7jbchtdgyOF8Io/1ng==\n' +
739+
'-----END EC PRIVATE KEY-----\n';
740+
741+
console.log(sign.sign(private_key).toString('hex'));
742+
```
743+
722744
### sign.sign(private_key[, output_format])
723745

724746
Calculates the signature on all the data passed through using either

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.