Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

mcrypt_rand rewrite in node js

var crypto = require('crypto');

var text = "Some super mega text I want encode";
var skey = "rcbTw667C7zxghZ5U3gwhQlp22t8c5Rq";

function encode(text, skey) {
    var len = text.length;
    var padSize = 16 - ((len + 16 - 1) % 16 + 1);
    for (var i = 0; i < padSize; i++) { 
        text += '';
    }
    var cipher = crypto.createCipheriv('aes-256-ecb', skey, '');
    cipher.setAutoPadding(false);
    var encrypted = cipher.update(text, 'utf8', 'base64');
    encrypted += cipher.final('base64');
    return encrypted;
}

console.log(encode(text, skey));
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery meta characters escape 
Javascript :: see more in jquery 
Javascript :: mongo look for substring of field 
Javascript :: on second click javascript 
Javascript :: on device size changes react-multi-carousel items not showing 
Javascript :: Angular generate by skipping test files 
Javascript :: how to connect two model in mongoose 
Javascript :: Scotch.io - Create a CRUD App with Node and MongoDB 2 App Foundation 
Javascript :: npx create-next-app permission denied 
Javascript :: fselect jquery 
Javascript :: c# to json online 
Javascript :: nestjs multer file upload delay 
Javascript :: nuxtjs install sassloader 
Javascript :: regex generator from text 
Javascript :: validate vpa api razorpay stackoverflow 
Javascript :: es6 syntax 
Javascript :: currentContract.transferFrom is not a function 
Javascript :: Print the third number from right 
Javascript :: react-spring 
Javascript :: I want to filter the below json data by start date and end date, it should return the data between start date and end date, 
Javascript :: qiankun angular 
Javascript :: remove nth character from string javascript 
Javascript :: allow only numbers in textbox javascript onkeypress 
Javascript :: proxy{} map in console 
Javascript :: Listen to custom event in Vue.js 
Javascript :: $() in javascript 
Javascript :: remove the bottom selection line from materail ui 
Javascript :: js notimplemented error 
Javascript :: nodejs split array into chunks 
Javascript :: Fetch data from multiple pages of an API in react native 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =