-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EXUI-2013: Resolve crypto-js CVE (#844)
* Update crypto-js, update cryptowrapper.ts * yarn audit --------- Co-authored-by: Andy Wilkins <[email protected]> Co-authored-by: RiteshHMCTS <[email protected]>
- Loading branch information
1 parent
726d3c3
commit 4f0669c
Showing
3 changed files
with
15 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { AES, enc, SHA256, WordArray } from 'crypto-js'; | ||
import { AES, enc, SHA256 } from 'crypto-js'; | ||
|
||
@Injectable() | ||
export class CryptoWrapper { | ||
public encrypt(message: string, secret: string = 'secret'): WordArray { | ||
const userIdEncrypted = AES.encrypt(message, secret, SHA256); | ||
return userIdEncrypted; | ||
public encrypt(message: string, secret: string = 'secret'): string { | ||
const key = SHA256(secret).toString(); | ||
return AES.encrypt(message, key).toString(); | ||
} | ||
|
||
public decrypt(encrypted: WordArray, secret: string = 'secret'): string { | ||
return AES.decrypt(encrypted, secret, SHA256).toString(enc.Utf8); | ||
public decrypt(encrypted: string, secret: string = 'secret'): string { | ||
const key = SHA256(secret).toString(); | ||
const bytes = AES.decrypt(encrypted, key); | ||
return bytes.toString(enc.Utf8); | ||
} | ||
} |
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