Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/softcreatr/wsc-crypto-ts

PoC of cryptographic utility functions for WoltLab Suite Core, implemented in TypeScript.
https://github.com/softcreatr/wsc-crypto-ts

crypto cryptography typescript woltlab wsc

Last synced: 21 days ago
JSON representation

PoC of cryptographic utility functions for WoltLab Suite Core, implemented in TypeScript.

Awesome Lists containing this project

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

```bash
npm install wsc-crypto-ts
```

## Usage

### Creating a Signed String

```typescript
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

```typescript
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](LICENSE.md) file for details.

## Author

- **Sascha Greuel**
- **Email:** [[email protected]](mailto:[email protected])
- **GitHub:** [SoftCreatR](https://github.com/SoftCreatR)