add keycrow feature ideas, exclude features/ from biome
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import CryptoJS from 'crypto-js';
|
||||
import { config } from '../config';
|
||||
|
||||
export class EncryptionService {
|
||||
private static instance: EncryptionService;
|
||||
private readonly key: string;
|
||||
|
||||
private constructor() {
|
||||
this.key = config.encryption.key;
|
||||
}
|
||||
|
||||
static getInstance(): EncryptionService {
|
||||
if (!EncryptionService.instance) {
|
||||
EncryptionService.instance = new EncryptionService();
|
||||
}
|
||||
return EncryptionService.instance;
|
||||
}
|
||||
|
||||
encrypt(plainText: string): string {
|
||||
return CryptoJS.AES.encrypt(plainText, this.key).toString();
|
||||
}
|
||||
|
||||
decrypt(cipherText: string): string {
|
||||
const bytes = CryptoJS.AES.decrypt(cipherText, this.key);
|
||||
return bytes.toString(CryptoJS.enc.Utf8);
|
||||
}
|
||||
|
||||
hash(data: string): string {
|
||||
return CryptoJS.SHA256(data).toString();
|
||||
}
|
||||
}
|
||||
|
||||
export const encryptionService = EncryptionService.getInstance();
|
||||
Reference in New Issue
Block a user