UNPKG

@qso-soft/shared

Version:

Shared library for QSO-soft

15 lines 613 B
import crypto from 'crypto'; export const hashString = (string) => crypto.createHash('sha256').update(string).digest('hex'); export const encodeString = (string) => { if (!string) return ''; const encodedSymbols = ['0x']; for (let symbolIndex = 0; symbolIndex < string.length; symbolIndex++) encodedSymbols.push(string.charCodeAt(symbolIndex).toString(16)); return encodedSymbols.join(''); }; export const getEncodedString = (string) => { const hashedString = hashString(string); return encodeString(hashedString).substring(0, 65); }; //# sourceMappingURL=encryption.js.map