1.0.0 • Published 7 years ago

koa-cookie-cipher-middleware v1.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

koa-cookie-cipher-middleware

simple cookie cipher middleware for koa2.

Installation

    npm install koa-cookie-cipher-middleware

Usage

    const app = new Koa();
    const Cipher = require('koa-cookie-cipher-middleware');
    const PORT = 3000;
    const TestMiddleware = async function(ctx,next) {
        console.log(`cipher name  slashhuang\n`);
        let cookieCipher = await ctx.cookie_decoder.cipher('slashhuang')
        console.log(`cipher slashhuang to ${cookieCipher}\n`);
        let cookieDecipher = await ctx.cookie_decoder.decipher('slashhuang');
        console.log(`decipher cookie ${cookieCipher} to ${cookieDecipher}`);
    }
    const MiddlewareArr = [ Cipher('hello'),TestMiddleware ];
    app.use(Compose(MiddlewareArr));
    app.listen(PORT);

demo page

cipher demo

Author

slashhuang

##License MIT