wsc-crypto-ts
v1.0.0
Published
PoC of cryptographic utility functions for WoltLab Suite Core, implemented in TypeScript.
Downloads
5
Maintainers
Readme
wsc-crypto-ts
PoC of cryptographic utility functions for WoltLab Suite Core, implemented in TypeScript.
Overview
This project provides cryptographic helper functions, including:
- Creating secure signatures based on the Keyed-Hash Message Authentication Code (HMAC) algorithm.
- Hexadecimal encoding and decoding without cache-timing leaks.
Installation
npm install wsc-crypto-ts
Usage
Creating a Signed String
import { createSignedStringForSession } from 'wsc-crypto-ts';
// Your session ID and secret
const sessionID = 'your-session-id';
const secret = 'your-secret-key';
// Create a signed string
const signedString = createSignedStringForSession(sessionID, secret);
console.log('Signed String:', signedString);
Verifying a Signed String
import { CryptoUtil } from 'wsc-crypto-ts';
// Initialize CryptoUtil with your secret
const cryptoUtil = new CryptoUtil(secret);
// Verify and decode the signed string
const decodedValue = cryptoUtil.verifySignedString(signedString);
if (decodedValue !== null) {
console.log('Decoded Value:', decodedValue.toString('utf8'));
} else {
console.error('Invalid signature!');
}
License
This project is licensed under the ISC License. See the LICENSE file for details.
Author
- Sascha Greuel
- Email: [email protected]
- GitHub: SoftCreatR