Become a Backer
- Overview
- Installation
- Actions
- Tasks
- Middleware
- Satellites
- Cluster
- Cache
- Chat
- Development Mode
- File System
- Events
- WebSocket
- TCP
- HTTP
- Security
- Validation
- Logging
- Commands
- Testing
Models
- Introduction
- Data Types and Attributes
- Instance and Class Methods
- Validations
- Associations
- Model Configuration
- Queries
Security
Introduction
Stellar comes equipped with a hashing system, which makes use of the bcrypt library. This allows you to compute hashes and compare them with clear text data to validate them.
It’s important that you set the default salt on production environment in order to increase the security of your API. You can do that setting the general.salt
config.
Compute Hashes
The api.hash.hash
and api.hash.hashSync
methods allow you to generate a hash from a string asynchronously and synchronously, respectively.
// generate a hash synchronously |
You can also use other salt with different resources, all you need is pass an extra hash with your special params who meets your needs:
hash.hashSync(plainData, { salt: yourSuperSalt }) |
Compare Hashes
The api.hash.compare
and api.hash.compareSync
methods allow you to compare a string with a hash to check whether they match.
// compare a hash synchronously |
← HTTP
Validation →
Caught a mistake or want to contribute to documentation?
Edit this page on Github!