Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

enigma-hash

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enigma-hash - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

4

index.js
const crypto = require("crypto")
function hash(input = "", type = "", code = "") {
function hash(input = "", type = "", code = "", key) {
const algorithms = ["sha256", "sha512"]

@@ -9,3 +9,3 @@

if (algorithms.includes(type)) {
const h = crypto.createHash(type)
const h = key ? crypto.createHmac(type, key) : crypto.createHash(type)
h.update(input)

@@ -12,0 +12,0 @@

@@ -12,2 +12,12 @@ const {hash} = require('./index')

expect(hash('Hello World', 'sha512', 'hex')).toEqual("2c74fd17edafd80e8447b0d46741ee243b7eb74dd2149a0ab1b9246fb30382f27e853d8585719e0e67cbda0daa8f51671064615d645ae27acb15bfb1447f459b")
})
})
// hmac sha256 test
test('sha256 Hmac test of Hello World', () => {
expect(hash('Hello World', 'sha256', 'hex', 'Some key')).toEqual("a722630ff96e1aece313dc76a6af89673884bbdb45adec31678f11e44e0578b7")
})
// hmac sha512 test
test('sha256 Hmac test of Hello World', () => {
expect(hash('Hello World', 'sha512', 'hex', 'Some key')).toEqual("8432d61b16b75978b3b8da48a10f44ea72aba3f66f283bdc696dccdff50a897bc946270501e9e4ee122d066b9aef2e60a8789aaf8d636b6a44521ba64371e109")
})
{
"name": "enigma-hash",
"version": "1.0.0",
"version": "1.0.1",
"description": "Demystifying the hashing of data",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -53,2 +53,10 @@ <div align="center">

Hash with a key (Hmac) like below:
```javascript
const hashValue = hash('Hello World', 'sha256', 'hex', 'Some key')
// hash(input, algorithm, code, key)
```
<table width="80%">

@@ -83,2 +91,9 @@ <tr>

</tr>
<tr>
<td><code>Key</code></td>
<td>Key used to encrypt data</td>
<td><code>String</code></td>
<td><code>Any</code></td>
<td><code>No key</code></td>
</tr>
</table>

@@ -85,0 +100,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc