1.0.0-alpha.11 • Published 2 years ago

@ngnjs/crypto v1.0.0-alpha.11

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

The NGN Cryptography plugin implements libcrypto, making it accessible from NGN and for all other NGN plugins. The following libcrypto methods are available:

  • generateKeys()
  • sign()
  • verify()
  • encrypt()
  • decrypt()
  • encryptJSON()
  • decryptJSON()
  • encryptionAlgorithm()

Notice: libcrypto contains additional features which aren't commonly used. This plugin exposes the minimum number of functions required to cover the most common cryptography needs in the smallest package possible. The other functions can be imported directly from libcrypto into projects that need them.

The fundamental/basic example:

import NGN from 'https://cdn.jsdelivr.net/npm/ngn@latest/index.js'
import 'https://cdn.jsdelivr.net/npm/@ngnjs/crypto/index.js'
// Alternative import:
// import crypto from 'https://cdn.jsdelivr.net/npm/@ngnjs/crypto/index.js'

// The crypto library is accessible from the NGN namespace
const crypto = NGN.plugins.crypto

// Key Generation
const { publicKey, privateKey } = await crypto.generateKeys()

// Content signing/verification
const content = 'my data'
const signature = await crypto.sign(content, privateKey)
const verified = await crypto.verify(content, signature, publicKey)

// Shared key encryption
const sharedKey = 'my secret'
const encrypted = await crypto.encrypt(content, sharedKey)
const decrypted = await crypto.decrypt(encrypted, sharedKey)

// Public key encryption/Private key decryption
const encrypted = await crypto.encrypt(content, publicKey)
const decrypted = await crypto.encrypt(content, privateKey)

For more specific examples and documentation, see the libcrypto repository.

1.0.0-alpha.9

2 years ago

1.0.0-alpha.8

3 years ago

1.0.0-alpha.7

3 years ago

1.0.0-alpha.10

2 years ago

1.0.0-alpha.11

2 years ago

1.0.0-alpha.6

3 years ago

1.0.0-alpha.5

3 years ago

1.0.0-alpha.4

3 years ago

1.0.0-alpha.3

3 years ago

1.0.0-alpha.2

3 years ago

1.0.0-alpha.1

3 years ago