otplib API Documentation / @otplib/core / / createCryptoPlugin
Function: createCryptoPlugin()
createCryptoPlugin(
options):CryptoPlugin
Defined in: packages/core/src/plugin-factories.ts:125
Create a custom Crypto plugin from crypto operation functions
Use this factory when you need a custom cryptographic implementation that doesn't fit the existing plugins (node, web, noble).
Parameters
options
Returns
Example
ts
import { createCryptoPlugin } from '@otplib/core';
const customCrypto = createCryptoPlugin({
name: 'my-crypto',
hmac: async (algorithm, key, data) => {
// Custom HMAC implementation
},
randomBytes: (length) => {
// Custom random bytes implementation
},
});