1.0.7 • Published 6 years ago

loopback-encryption-mixin v1.0.7

Weekly downloads
44
License
MIT
Repository
github
Last release
6 years ago

Installation npm i --save loopback-encryption-mixin

In your model-config.json: add "../node_modules/loopback-encryption-mixin" as a mixin

{
    "...": "...",
    "mixins": [
      "loopback/common/mixins",
      "loopback/server/mixins",
      "../common/mixins",
      "./mixins",
      "../node_modules/loopback-encryption-mixin"
    ],
    "....": "..."
}

Then add the mixin to your model

{
"...": "...",
"mixins": {
    "Encryption": {
      "fields": ["name"],
      "password": "mypassword",
      "salt": "jkncjahksdjahsdkjhasjdhasdhkjasna",
      "iteration": 100,
      "hashBytes": 16,
      "hashAlgorithm": "sha1",
      "hexIv": "cd5c632d26fde5e2eb61e521ad2b91ba",
      "encryptionAlgorithm": "aes-128-cbc"
    }
  },
 "properties": {
    "...": "..."
  },
 "....": "..."
 }

Options Explained

OptionsDescription
fieldsthe properties of the model that need to be encrypted
passwordthe password of the encryption
saltsalt for hashing the password
iterationiteration of the hash
hashBytesthe hash bytes corresponding to your hash algorithm and encryption algorithm
hashAlgorithmHash algorithm
hexIviv used for encryption in HEX format
encryptionAlgorithmEncryption Algorithm corresponding to your iv and password format
1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

0.0.1

6 years ago