-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from Cryptographic-API-Services/pre-release
#22 password hasing threadpool
- Loading branch information
Showing
12 changed files
with
255 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
export interface IPasswordHasherBase { | ||
hashPassword(password: string): string; | ||
verify(hashedPassword: string, passwordToVerify: string): boolean; | ||
hashPasswordThreadPool(password: string): string; | ||
verifyThreadPool(hashedPassword: string, passwordToCheck: string): boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,37 @@ | ||
import { scryptHash, scryptVerify } from "../../index"; | ||
import { scryptHash, scryptHashThreadpool, scryptVerify, scryptVerifyThreadpool } from "../../index"; | ||
import { IPasswordHasherBase } from "./password-hasher-base"; | ||
|
||
export class ScryptWrapper implements IPasswordHasherBase { | ||
|
||
public hashPassword(password: string): string { | ||
if (!password){ | ||
throw new Error("You must provide a password to hash with Scrypt"); | ||
} | ||
return scryptHash(password); | ||
} | ||
|
||
public verify(hashedPassword: string, passwordToVerify: string): boolean { | ||
if (!hashedPassword || !passwordToVerify) { | ||
throw new Error("You must provide a hashed password and a plaintext password to verify with Scrypt"); | ||
} | ||
return scryptVerify(hashedPassword, passwordToVerify); | ||
} | ||
verifyThreadPool(hashedPassword: string, passwordToCheck: string): boolean { | ||
if (!hashedPassword || !passwordToCheck) { | ||
throw new Error( | ||
"You must provide a hashed password and a plaintext password to verify with Scrypt", | ||
); | ||
} | ||
return scryptVerifyThreadpool(hashedPassword, passwordToCheck); | ||
} | ||
|
||
} | ||
hashPasswordThreadPool(password: string): string { | ||
if (!password) { | ||
throw new Error("You must provide a password to hash with Scrypt"); | ||
} | ||
return scryptHashThreadpool(password); | ||
} | ||
|
||
public hashPassword(password: string): string { | ||
if (!password) { | ||
throw new Error("You must provide a password to hash with Scrypt"); | ||
} | ||
return scryptHash(password); | ||
} | ||
|
||
public verify(hashedPassword: string, passwordToVerify: string): boolean { | ||
if (!hashedPassword || !passwordToVerify) { | ||
throw new Error( | ||
"You must provide a hashed password and a plaintext password to verify with Scrypt", | ||
); | ||
} | ||
return scryptVerify(hashedPassword, passwordToVerify); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.