From ddf590e5cb5993c5f6c6f3a6471cf30190f6a602 Mon Sep 17 00:00:00 2001 From: satya319 Date: Sun, 27 Mar 2022 21:51:10 +0530 Subject: [PATCH] version up, passport & dl num generate fun added --- .gitignore | 4 + README.md | 15 +- package/LICENSE | 15 + package/dataProvider.js | 14 +- package/index.js | 979 ++++++++++++++++++++-------------------- package/package.json | 2 +- package/readme.md | 14 +- test-folder/.gitignore | 4 + test-folder/script.mjs | 107 ++--- 9 files changed, 600 insertions(+), 554 deletions(-) create mode 100644 .gitignore create mode 100644 package/LICENSE create mode 100644 test-folder/.gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba62d06 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/node_modules +copyed.js +data.js + diff --git a/README.md b/README.md index c3c2bcb..6f2f783 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Pirated-Data - [![CodeFactor](https://www.codefactor.io/repository/github/satya319/pirated-data/badge)](https://www.codefactor.io/repository/github/satya319/pirated-data) + ![CodeFactor](https://www.codefactor.io/repository/github/satya319/pirated-data/badge/main) **Install the package via npm** ``` @@ -25,6 +25,8 @@ npm i pirated-data - [User Id](#User-Id) - [Password](#Password) - [PanCard ID](#PanCard-ID) +- [Passport Number](#Passport-Number) +- [Driving license number](#Driving-license-number) - [Financial card](#Financial-card) - [Card Number](#Card-Number) - [Card Holder Name](#Card-Holder-Name) @@ -79,9 +81,6 @@ var card = userData.financialCardGenerator(); const userData = require('pirated-data'); var bnkName = userData.bankNameGenerator(); - - - // For getting AadharCard number const userData = require('pirated-data'); var aadhar = userData.aadharNumberGenerator(); @@ -105,6 +104,14 @@ var pwd = userData.password(10); var id = userData.panCardId(); console.log(id); +/*For getting passport number */ + const passNum = userData.passportNumber(); + console.log(passNum); + +/*For getting DL number */ +const dl = userData.drivinglicenseGenerator(); +console.log(dl); + /* For generating Gendor of an user */ const userData = require('pirated-data'); var gender = userData.genderGenerator(); diff --git a/package/LICENSE b/package/LICENSE new file mode 100644 index 0000000..0e90481 --- /dev/null +++ b/package/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2016, Internet Systems Consortium, Inc. ("ISC") + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file diff --git a/package/dataProvider.js b/package/dataProvider.js index b686d21..2d75705 100644 --- a/package/dataProvider.js +++ b/package/dataProvider.js @@ -162,6 +162,16 @@ var stateDist ={'Andhra Pradesh': ['Anantapuram', 'Chittoor', 'East Godavari', ' var stateList={"Andhra Pradesh":13,"Arunachal Pradesh":26,"Assam":34,"Bihar":38,"Chhattisgarh":28,"Goa":2, "Gujarat":33,"Haryana":22,"Himachal Pradesh":12,"Jharkhand":24,"Karnataka":31,"Kerala":14,"Madhya Pradesh":52, "Maharashtra":36,"Manipur":16,"Meghalaya":12,"Mizoram":8,"Nagaland":11,"Odisha":30,"Punjab":23,"Rajasthan":33, -"Sikkim":4,"Tamil Nadu":38,"Telangana":33,"Tripura":8,"Uttar Pradesh":75,"Uttarakhand":13, "West Bengal":23} +"Sikkim":4,"Tamil Nadu":38,"Telangana":33,"Tripura":8,"Uttar Pradesh":75,"Uttarakhand":13, "West Bengal":23}; + +var stateRtoCode={"Andhra Pradesh":"AP","Arunachal Pradesh":"AR","Assam":"AS","Bihar":"BR","Chhattisgarh":"CG","Goa":"GA", +"Gujarat":"GJ","Haryana":"HR","Himachal Pradesh":"HP","Jharkhand":"JH","Karnataka":"KA","Kerala":"KL","Madhya Pradesh":"MP", +"Maharashtra":"MH","Manipur":"MN","Meghalaya":"ML","Mizoram":"MZ","Nagaland":"NL","Odisha":"OD","Punjab":"PN","Rajasthan":"RJ", +"Sikkim":"SK","Tamil Nadu":"TN","Telangana":"TS","Tripura":"TR","Uttar Pradesh":"UP","Uttarakhand":"UK", "West Bengal":"WB"}; + +var stateRtoCount={"Andhra Pradesh":38,"Arunachal Pradesh":16,"Assam":34,"Bihar":11,"Chhattisgarh":30,"Goa":6, +"Gujarat":38,"Haryana":98,"Himachal Pradesh":80,"Jharkhand":24,"Karnataka":71,"Kerala":86,"Madhya Pradesh":54, +"Maharashtra":50,"Manipur":8,"Meghalaya":14,"Mizoram":9,"Nagaland":8,"Odisha":35,"Punjab":99,"Rajasthan":53, +"Sikkim":8,"Tamil Nadu":96,"Telangana":36,"Tripura":8,"Uttar Pradesh":96,"Uttarakhand":19, "West Bengal":78}; module.exports = { firstMaleName, title,emlDomain, gender, hairColor, skinColor, bloodGroup, eyeColor, - stateName, stateDist ,stateList}; + stateName, stateDist ,stateList, stateRtoCode, stateRtoCount}; \ No newline at end of file diff --git a/package/index.js b/package/index.js index cdb64c6..592c5a4 100644 --- a/package/index.js +++ b/package/index.js @@ -1,504 +1,499 @@ /*! * @author Satyajit319 * date 03/03/2022 */ -const { firstMaleName, title, emlDomain, gender, hairColor, skinColor, bloodGroup, eyeColor, stateName, stateDist,stateList} = require('./dataProvider.js'); - -var actfirName = ""; -var actlstName = ""; -var actFullName = ""; -var actGender = ""; -var actHairColor = ""; -var actEyeColor = ""; -var panNo = ""; -var actBloodGroup = ""; -var actWeight = ""; -var actSkinColor = ""; -var actStateName = ""; -var actDistName = ""; -var actCardFullDetails = ""; -var firstDate1 = ""; -var actAge = ""; -var secondDate = new Date(2012, 4, 12);// every year to be increase one year. - - -/** - * This method can generate random First name of a person. - * @returns firstName - */ -function firstNameGenerator() { - var number = Math.floor(Math.random() * 469); - //var lengthofarray = firstMaleName.length; - return actfirName = firstMaleName[number]; -} -exports.firstNameGenerator = firstNameGenerator; -/** - * This method can generate random Last name of a person. - * @returns LastName - */ -function lastNameGenerator() { - var number = Math.floor(Math.random() * 806); - return actlstName = title[number]; -} -exports.lastNameGenerator = lastNameGenerator; -/** - * This method can generate full name of a person. - * @returns FullName - */ -function fullNameGenerator() { - if (actfirName == "") { - this.firstNameGenerator(); - } - if (actlstName == "") { - this.lastNameGenerator(); - } - var fullName = actfirName + " " + actlstName; - return actFullName = fullName; -} -exports.fullNameGenerator = fullNameGenerator; -/** - * This method is for generate random age between (18-99). - * @returns age - * @deprecated - */ -function adultAgeGenerator() { - var age = Math.floor(Math.random() * (99 - 18 + 1)) + 18; - return ageYrs = age; -} -exports.adultAgeGenerator = adultAgeGenerator; -/** - * This method is for generate random mobile number - * @returns MobileNumber - */ -function mobileNumberGenerator() { - var mobNumber = Math.floor(Math.random() * (9999999999 - 6000000000 + 1)) + 6000000000; - return mobNumber; -} -exports.mobileNumberGenerator = mobileNumberGenerator; -/** - * This method generates aadharnumber of a person - * @returns aadharnumber - */ -function aadharNumberGenerator() { - var adharNum = Math.floor(Math.random() * (999999999999 - 100000000000 + 1)) + 100000000000; - return adharNum; -} -exports.aadharNumberGenerator = aadharNumberGenerator; -/** - * This method generte unique emailId every time. - * @returns emailId - */ -function emailIdGenerator() { - var emlNum = Math.floor(Math.random() * (999 - 100 + 1)) + 100; - var domain = Math.floor(Math.random() * 10); - if (actfirName == "") { - this.firstNameGenerator(); - } - return actfirName + emlNum + '@' + emlDomain[domain]; -} -exports.emailIdGenerator = emailIdGenerator; -/** - * This method gives the random user Id according to the first name of the person. - * @returns userId - */ -function userIdGenerator() { - if (actfirName == "") { - this.firstNameGenerator(); - } - var usrIdNum = Math.floor(Math.random() * (999 - 100 + 1)) + 100; - return userId = actfirName + usrIdNum; -} -exports.userIdGenerator = userIdGenerator; -/** - * This method generate a strong alpha numeric password. - * @argument lengthofPassword - * - * @returns password - */ -function passwordGenerator(len) { - var str = ""; - for (var i = 0; i < len; i++) { - var rand = Math.floor(Math.random() * 62); - var charCode = rand += rand > 9 ? (rand < 36 ? 55 : 61) : 48; - str += String.fromCharCode(charCode); - } - return str; -} -exports.passwordGenerator = passwordGenerator; -/** - * This function have the work of generating person's pan card number(India format) - * @returns panNo - */ -function panCardId() { - var result = ''; - var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - var charactersLength = characters.length; - for (var i = 0; i < 3; i++) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - if (actlstName == "") { - this.lastNameGenerator(); - } - var lastNamefirstChar = actlstName.substring(0, 1); - var num = Math.floor(Math.random() * (9999 - 1000 + 1)) + 1000; - const lastChar = characters.charAt(Math.floor(Math.random() * 26)) - panNo = result + "P" + lastNamefirstChar + num + lastChar; - return panNo; -} -exports.panCardId = panCardId; -/** - * This method generate a gender for user. - * @returns gender - */ -function genderGenerator() { - var gen = Math.floor(Math.random() * 3); - return actGender = gender[gen]; -} -exports.genderGenerator = genderGenerator; -/** - * This function gives the date of birth of an user. - * @param {*} start - * @param {*} end +const { firstMaleName, title, emlDomain, gender, hairColor, skinColor, bloodGroup, eyeColor, stateName, stateDist, + stateList,stateRtoCode,stateRtoCount } = require('./dataProvider.js'); + + var actfirName = ""; + var actlstName = ""; + var actFullName = ""; + var actGender = ""; + var actHairColor = ""; + var actEyeColor = ""; + var panNo = ""; + var passNo = ""; + var dlNum = ""; + var actBloodGroup = ""; + var actWeight = ""; + var actSkinColor = ""; + var actStateName = ""; + var actDistName = ""; + var actCardFullDetails = ""; + var firstDate1 = ""; + var actAge = ""; + var secondDate = new Date(2012, 4, 12);// every year to be increase one year. + + /** + * This method can generate random First name of a person. + * @returns firstName + */ + function firstNameGenerator() { + var number = Math.floor(Math.random() * 469); + //var lengthofarray = firstMaleName.length; + return actfirName = firstMaleName[number]; + } + exports.firstNameGenerator = firstNameGenerator; + /** + * This method can generate random Last name of a person. + * @returns LastName + */ + function lastNameGenerator() { + var number = Math.floor(Math.random() * 806); + return actlstName = title[number]; + } + exports.lastNameGenerator = lastNameGenerator; + /** + * This method can generate full name of a person. + * @returns FullName + */ + function fullNameGenerator() { + if (actfirName == "") { + this.firstNameGenerator(); + } + if (actlstName == "") { + this.lastNameGenerator(); + } + var fullName = actfirName + " " + actlstName; + return actFullName = fullName; + } + exports.fullNameGenerator = fullNameGenerator; + /** + * This method is for generate random age between (18-99). + * @returns age + * @deprecated + */ + function adultAgeGenerator() { + var age = Math.floor(Math.random() * (99 - 18 + 1)) + 18; + return ageYrs = age; + } + exports.adultAgeGenerator = adultAgeGenerator; + /** + * This method is for generate random mobile number + * @returns MobileNumber + */ + function mobileNumberGenerator() { + var mobNumber = Math.floor(Math.random() * (9999999999 - 6000000000 + 1)) + 6000000000; + return mobNumber; + } + exports.mobileNumberGenerator = mobileNumberGenerator; + /** + * This method generates aadharnumber of a person + * @returns aadharnumber + */ + function aadharNumberGenerator() { + var adharNum = Math.floor(Math.random() * (999999999999 - 100000000000 + 1)) + 100000000000; + return adharNum; + } + exports.aadharNumberGenerator = aadharNumberGenerator; + /** + * This method generte unique emailId every time. + * @returns emailId + */ + function emailIdGenerator() { + var emlNum = Math.floor(Math.random() * (999 - 100 + 1)) + 100; + var domain = Math.floor(Math.random() * 10); + if (actfirName == "") { + this.firstNameGenerator(); + } + return actfirName + emlNum + '@' + emlDomain[domain]; + } + exports.emailIdGenerator = emailIdGenerator; + /** + * This method gives the random user Id according to the first name of the person. + * @returns userId + */ + function userIdGenerator() { + if (actfirName == "") { + this.firstNameGenerator(); + } + var usrIdNum = Math.floor(Math.random() * (999 - 100 + 1)) + 100; + return userId = actfirName + usrIdNum; + } + exports.userIdGenerator = userIdGenerator; + /** + * This method generate a strong alpha numeric password. + * @argument lengthofPassword + * + * @returns password + */ + function passwordGenerator(len) { + var str = ""; + for (var i = 0; i < len; i++) { + var rand = Math.floor(Math.random() * 62); + var charCode = rand += rand > 9 ? (rand < 36 ? 55 : 61) : 48; + str += String.fromCharCode(charCode); + } + return str; + } + exports.passwordGenerator = passwordGenerator; + /** + * This function have the work of generating person's pan card number(India format) + * @returns panNo + */ + function panCardId() { + var result = ''; + var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + var charactersLength = characters.length; + for (var i = 0; i < 3; i++) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); + } + if (actlstName == "") { + this.lastNameGenerator(); + } + var lastNamefirstChar = actlstName.substring(0, 1); + var num = Math.floor(Math.random() * (9999 - 1000 + 1)) + 1000; + const lastChar = characters.charAt(Math.floor(Math.random() * 26)) + panNo = result + "P" + lastNamefirstChar + num + lastChar; + return panNo; + } + exports.panCardId = panCardId; + /** + * This function will give you the random sample passport number for Indian citizen. + * @returns passNo + */ + function passportNumber() { + const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + const charactersLength = characters.length; + result = characters.charAt(Math.floor(Math.random() * charactersLength)); + var num = Math.floor(Math.random() * (999999999 - 100000000 + 1)) + 100000000; + passNo = result + num; + return passNo; + } + exports.passportNumber = passportNumber; + + /** + * This function generates the random Driving license number. * @returns */ -function birthDateTimeGenerator() { - const start = new Date("1935-01-01"); - const end = new Date(2002, 0, 1); - const dob = new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime())); - const r = dob.toISOString().slice(0, 10); - const firstDate2 = r.split("-"); - const yr = firstDate2[0]; - const mn = firstDate2[1]; - const dy = firstDate2[2]; - firstDate1 = yr + "-" + mn + "-" + dy; - return firstDate1; - // return new Date(); -} -exports.birthDateTimeGenerator = birthDateTimeGenerator; -/** - * This function gives age of the user. - * @returns age - */ -function ageCalculation() { - if (firstDate1 == "") { - this.birthDateTimeGenerator(); - } - var firstDate = new Date(firstDate1); - secondDate = new Date(); - if (firstDate > secondDate) - [firstDate, secondDate] = [secondDate, firstDate]; - - let monthDiff = 0; - let isDayAhead = secondDate.getDate() >= firstDate.getDate(); - - if (secondDate.getMonth() >= firstDate.getMonth()) { - let diff = secondDate.getMonth() - firstDate.getMonth(); - monthDiff += (isDayAhead) ? diff : diff - 1; - } - else { - monthDiff += isDayAhead - ? 12 - (firstDate.getMonth() - secondDate.getMonth()) - : 12 - (firstDate.getMonth() - secondDate.getMonth()) - 1; - } - - let dayDiff = 0; - - if (isDayAhead) { - dayDiff = secondDate.getDate() - firstDate.getDate(); - } - else { - let b4EndDate = new Date( - secondDate.getFullYear(), - secondDate.getMonth() - 1, - firstDate.getDate() - ) - dayDiff = getDaysDiff(b4EndDate, secondDate); - } - - if (firstDate.getMonth() == secondDate.getMonth() && !isDayAhead) - monthDiff = 11; - - let exactTimeDiffUnits = { - yrs: getYearsDiff(firstDate, secondDate), - mths: monthDiff, - dys: dayDiff, - }; - actAge = `${exactTimeDiffUnits.yrs} years, ${exactTimeDiffUnits.mths} months, ${exactTimeDiffUnits.dys} days`; - return actAge; -} -exports.ageCalculation = ageCalculation; -// time difference in Days -function getDaysDiff(startDate = new Date(), endDate = new Date()) { - console.log("daydiff: ", startDate); - if (startDate > endDate) [startDate, endDate] = [endDate, startDate]; - - let timeDiff = endDate - startDate; - let timeDiffInDays = Math.floor(timeDiff / (1000 * 3600 * 24)); - - return timeDiffInDays; -} - -// time difference in Months -function getMonthsDiff(startDate = new Date(), endDate = new Date()) { - console.log("monthdiff: ", startDate); - let monthsOfFullYears = getYearsDiff(startDate, endDate) * 12; - let months = monthsOfFullYears; - // the variable below is not necessary, but I kept it for understanding of code - // we can use "startDate" instead of it - let yearsAfterStart = new Date( - startDate.getFullYear() + getYearsDiff(startDate, endDate), - startDate.getMonth(), - startDate.getDate() - ); - let isDayAhead = endDate.getDate() >= yearsAfterStart.getDate(); - - if (startDate.getMonth() == endDate.getMonth() && !isDayAhead) { - months = 11; - return months; - } - - if (endDate.getMonth() >= yearsAfterStart.getMonth()) { - let diff = endDate.getMonth() - yearsAfterStart.getMonth(); - months += (isDayAhead) ? diff : diff - 1; - } - else { - months += isDayAhead - ? 12 - (startDate.getMonth() - endDate.getMonth()) - : 12 - (startDate.getMonth() - endDate.getMonth()) - 1; - } - - return months; -} - -// time difference in Years -function getYearsDiff(startDate = new Date(), endDate = new Date()) { - console.log("yrdiff: ", startDate); - if (startDate > endDate) [startDate, endDate] = [endDate, startDate]; - - let yearB4End = new Date( - endDate.getFullYear() - 1, - endDate.getMonth(), - endDate.getDate() - ); - let year = 0; - year = yearB4End > startDate - ? yearB4End.getFullYear() - startDate.getFullYear() - : 0; - let yearsAfterStart = new Date( - startDate.getFullYear() + year + 1, - startDate.getMonth(), - startDate.getDate() - ); - - if (endDate >= yearsAfterStart) year++; - - return year; -} - - -/** - * This method generates random hair color of a human - * @returns haircolor - */ -function hairColorGenerator() { - var hairclr = Math.floor(Math.random() * 4); - return actHairColor = hairColor[hairclr]; -} -exports.hairColorGenerator = hairColorGenerator; -/** - * This method generates eyecolor of a humanbeing. - * @returns eyecolor - */ -function eyeColorGenerator() { - var eyeclr = Math.floor(Math.random() * 7); - return actEyeColor = eyeColor[eyeclr]; -} -exports.eyeColorGenerator = eyeColorGenerator; -/** - * This function generate blood group for user. - * @returns bloodgroup - */ -function bloodGroupGenerator() { - var bldgrp = Math.floor(Math.random() * 8); - return actBloodGroup = bloodGroup[bldgrp]; -} -exports.bloodGroupGenerator = bloodGroupGenerator; -/** - * This method generate random weight of a user values are in between(35-109) - * @returns weight - */ -function weightGenerator() { - var wt = Math.floor(Math.random() * (109 - 35 + 1)) + 35; - return actWeight = wt; -} -exports.weightGenerator = weightGenerator; -/** - * This method gives skin color of an user. - * @returns skincolor - */ -function skinColorGenerator() { - var sknclr = Math.floor(Math.random() * 25); - return actSkinColor = skinColor[sknclr]; -} -exports.skinColorGenerator = skinColorGenerator; -// Biological details generator -/** - * This function give you all the basic bioligical data of an user. - * @returns Name, gender, haircolor, age, eyeclolor, blood group, weight, skin color. - */ -function BiologicalData() { - - if (actfirName == "") { - this.firstNameGenerator(); - } - if (actlstName == "") { - this.lastNameGenerator(); - } - if (actGender == "") { - this.genderGenerator(); - } - if (actHairColor == "") { - this.hairColorGenerator(); - } - if (firstDate1 == "") { - this.birthDateTimeGenerator(); - } - // else if (actAge == "") { - // this.adultAgeGenerator(); - // } - if (actAge == "") { - this.ageCalculation(); - } - if (actEyeColor == "") { - this.eyeColorGenerator(); - } - if (actBloodGroup == "") { - this.bloodGroupGenerator(); - } - if (actWeight == "") { - this.weightGenerator(); - } - if (actSkinColor == "") { - this.skinColorGenerator(); - } - - return [actfirName, actlstName, actGender, actHairColor, firstDate1, actAge, actEyeColor, actBloodGroup, actWeight, actSkinColor]; -} -exports.BiologicalData = BiologicalData; - -/** - * This function generate a state(Indian) for user. - * @returns stateName - */ -function stateGenerator() { - var number = Math.floor(Math.random() * 28); - return actStateName = stateName[number]; -} -exports.stateGenerator = stateGenerator; -/** - * This method can generate the district name for user. - * - * @returns districtName - */ -function distGenerator() { - +function drivinglicenseGenerator(){ if (actStateName == "") { this.stateGenerator(); } if(actStateName){ - var dis = Math.floor(Math.random() * stateList[actStateName]); - actDistName = stateDist[actStateName][dis]; - } - return actDistName; -} -exports.distGenerator = distGenerator; - -/** - * This function generate address of an user. - * Dependent on the other functions - * - * - * @returns fullname,statename, districtname - */ -// Address of an user -function addressGenerator() { - if (actFullName == "") { - this.fullNameGenerator(); - } - if (actStateName == "") { - this.stateGenerator(); +var rtoCode = stateRtoCode[actStateName]; } - if (actDistName == "") { - this.distGenerator(); - } - return [actFullName, actStateName, actDistName]; -} -exports.addressGenerator = addressGenerator; - - -//Financial Details -/** - * This function generate a virtual visa card Details - * @returns card holder name, card number, validThru, cvv - */ -function financialCardGenerator() { - if (actFullName == "") { - this.fullNameGenerator(); - } - var validMnth = Math.floor(Math.random() * 12); - var validYr = Math.floor(Math.random() * (2027 - 2022 + 1)) + 2022; - var cvv = Math.floor(Math.random() * (999 - 100 + 1)) + 100; - var visaElectronNum = Math.floor(Math.random() * (4999999999999999 - 4101110010111111 + 1)) + 4101110010111111; - var validThru = validMnth + "/" + validYr; - actCardFullDetails = [actFullName, visaElectronNum, validThru, cvv]; - return actCardFullDetails; -} -exports.financialCardGenerator = financialCardGenerator; - -/** - * This function gives you the bunch set of random address data - * in the form of array set. - * @param desiredDataSetNumber - * @returns bunchAddress - */ -function hugeAddressGenerator(desiredDataSetNumber) { - var bunchAddress = []; - for (let i = 0; i < desiredDataSetNumber; i++) { - actFullName = firstMaleName[Math.floor(Math.random() * 469)] + ' ' + title[Math.floor(Math.random() * 10)]; - state = this.stateGenerator(); - dist = this.distGenerator(); - bunchAddress.push([actFullName, state, dist]); - } - return bunchAddress; + if(actStateName){ + var rtoNum = Math.floor(Math.random() * stateRtoCount[actStateName]); + // actDistName = stateDist[actStateName]; + if(rtoNum >=1 && rtoNum<10){ + rtoNum ="0" + rtoNum ; + } + else if(rtoNum == 0){ + rtoNum ="01"; + } + } + const yr = Math.floor(Math.random() * (2022 - 1998 + 1)) + 1998; + const appNo = Math.floor(Math.random() * (8888888 - 1000000 + 1)) + 1000000; + const dl = rtoCode + rtoNum + yr + appNo; + return dlNum = dl; } -exports.hugeAddressGenerator = hugeAddressGenerator; -/** - * This function gives you the bunch set of random biological data - * in the form of array set. - * @param desiredDataSetNumber - * @returns bunchBio - */ -function hugeBiologicalDataGenerator(desiredDataSetNumber) { - var bunchBio = []; - for (let i = 0; i < desiredDataSetNumber; i++) { - var fulName = firstMaleName[Math.floor(Math.random() * 469)] + ' ' + title[Math.floor(Math.random() * 10)]; - var gen = gender[Math.floor(Math.random() * 3)]; - var hairclr = hairColor[Math.floor(Math.random() * 4)]; - //var age = Math.floor(Math.random() * (99 - 18 + 1)) + 18; - var dob = this.birthDateTimeGenerator(); - var age = this.ageCalculation(); - var eyeclr = eyeColor[Math.floor(Math.random() * 7)]; - var bldGrp = bloodGroup[Math.floor(Math.random() * 8)]; - var weight = Math.floor(Math.random() * (109 - 35 + 1)) + 35; - var sknClr = skinColor[Math.floor(Math.random() * 25)]; - bunchBio.push([fulName, gen, hairclr, dob, age, eyeclr, bldGrp, weight, sknClr]); +exports.drivinglicenseGenerator = drivinglicenseGenerator; + /** + * This method generate a gender for user. + * @returns gender + */ + function genderGenerator() { + var gen = Math.floor(Math.random() * 3); + return actGender = gender[gen]; + } + exports.genderGenerator = genderGenerator; + /** + * This function gives the date of birth of an user. + * @param {*} start + * @param {*} end + * @returns + */ + function birthDateTimeGenerator() { + const start = new Date("1935-01-01"); + const end = new Date(2002, 0, 1); + const dob = new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime())); + const r = dob.toISOString().slice(0, 10); + const firstDate2 = r.split("-"); + const yr = firstDate2[0]; + const mn = firstDate2[1]; + const dy = firstDate2[2]; + firstDate1 = yr + "-" + mn + "-" + dy; + return firstDate1; + // return new Date(); + } + exports.birthDateTimeGenerator = birthDateTimeGenerator; + /** + * This function gives age of the user. + * @returns age + */ + function ageCalculation() { + if (firstDate1 == "") { + this.birthDateTimeGenerator(); + } + var firstDate = new Date(firstDate1); + secondDate = new Date(); + if (firstDate > secondDate) + [firstDate, secondDate] = [secondDate, firstDate]; + + let monthDiff = 0; + let isDayAhead = secondDate.getDate() >= firstDate.getDate(); + + if (secondDate.getMonth() >= firstDate.getMonth()) { + let diff = secondDate.getMonth() - firstDate.getMonth(); + monthDiff += (isDayAhead) ? diff : diff - 1; + } + else { + monthDiff += isDayAhead + ? 12 - (firstDate.getMonth() - secondDate.getMonth()) + : 12 - (firstDate.getMonth() - secondDate.getMonth()) - 1; + } + + let dayDiff = 0; + + if (isDayAhead) { + dayDiff = secondDate.getDate() - firstDate.getDate(); + } + else { + let b4EndDate = new Date( + secondDate.getFullYear(), + secondDate.getMonth() - 1, + firstDate.getDate() + ) + dayDiff = getDaysDiff(b4EndDate, secondDate); + } + + if (firstDate.getMonth() == secondDate.getMonth() && !isDayAhead) + monthDiff = 11; + + let exactTimeDiffUnits = { + yrs: getYearsDiff(firstDate, secondDate), + mths: monthDiff, + dys: dayDiff, + }; + actAge = `${exactTimeDiffUnits.yrs} years, ${exactTimeDiffUnits.mths} months, ${exactTimeDiffUnits.dys} days`; + return actAge; + } + exports.ageCalculation = ageCalculation; + // time difference in Days + function getDaysDiff(startDate = new Date(), endDate = new Date()) { + console.log("daydiff: ", startDate); + if (startDate > endDate) [startDate, endDate] = [endDate, startDate]; + let timeDiff = endDate - startDate; + let timeDiffInDays = Math.floor(timeDiff / (1000 * 3600 * 24)); + return timeDiffInDays; } - return bunchBio; -} -exports.hugeBiologicalDataGenerator = hugeBiologicalDataGenerator; - - - - - - - + + // time difference in Years + function getYearsDiff(startDate = new Date(), endDate = new Date()) { + console.log("yrdiff: ", startDate); + if (startDate > endDate) [startDate, endDate] = [endDate, startDate]; + let yearB4End = new Date( + endDate.getFullYear() - 1, + endDate.getMonth(), + endDate.getDate() + ); + let year = 0; + year = yearB4End > startDate + ? yearB4End.getFullYear() - startDate.getFullYear() + : 0; + let yearsAfterStart = new Date( + startDate.getFullYear() + year + 1, + startDate.getMonth(), + startDate.getDate() + ); + if (endDate >= yearsAfterStart) year++; + return year; + } + + /** + * This method generates random hair color of a human + * @returns haircolor + */ + function hairColorGenerator() { + var hairclr = Math.floor(Math.random() * 4); + return actHairColor = hairColor[hairclr]; + } + exports.hairColorGenerator = hairColorGenerator; + /** + * This method generates eyecolor of a humanbeing. + * @returns eyecolor + */ + function eyeColorGenerator() { + var eyeclr = Math.floor(Math.random() * 7); + return actEyeColor = eyeColor[eyeclr]; + } + exports.eyeColorGenerator = eyeColorGenerator; + /** + * This function generate blood group for user. + * @returns bloodgroup + */ + function bloodGroupGenerator() { + var bldgrp = Math.floor(Math.random() * 8); + return actBloodGroup = bloodGroup[bldgrp]; + } + exports.bloodGroupGenerator = bloodGroupGenerator; + /** + * This method generate random weight of a user values are in between(35-109) + * @returns weight + */ + function weightGenerator() { + var wt = Math.floor(Math.random() * (109 - 35 + 1)) + 35; + return actWeight = wt; + } + exports.weightGenerator = weightGenerator; + /** + * This method gives skin color of an user. + * @returns skincolor + */ + function skinColorGenerator() { + var sknclr = Math.floor(Math.random() * 25); + return actSkinColor = skinColor[sknclr]; + } + exports.skinColorGenerator = skinColorGenerator; + // Biological details generator + /** + * This function give you all the basic bioligical data of an user. + * @returns Name, gender, haircolor, age, eyeclolor, blood group, weight, skin color. + */ + function BiologicalData() { + + if (actfirName == "") { + this.firstNameGenerator(); + } + if (actlstName == "") { + this.lastNameGenerator(); + } + if (actGender == "") { + this.genderGenerator(); + } + if (actHairColor == "") { + this.hairColorGenerator(); + } + if (firstDate1 == "") { + this.birthDateTimeGenerator(); + } + // else if (actAge == "") { + // this.adultAgeGenerator(); + // } + if (actAge == "") { + this.ageCalculation(); + } + if (actEyeColor == "") { + this.eyeColorGenerator(); + } + if (actBloodGroup == "") { + this.bloodGroupGenerator(); + } + if (actWeight == "") { + this.weightGenerator(); + } + if (actSkinColor == "") { + this.skinColorGenerator(); + } + return [actfirName, actlstName, actGender, actHairColor, firstDate1, actAge, actEyeColor, actBloodGroup, actWeight, actSkinColor]; + } + exports.BiologicalData = BiologicalData; + + /** + * This function generate a state(Indian) for user. + * @returns stateName + */ + function stateGenerator() { + var number = Math.floor(Math.random() * 28); + return actStateName = stateName[number]; + } + exports.stateGenerator = stateGenerator; + /** + * This method can generate the district name for user. + * + * @returns districtName + */ + function distGenerator() { + if (actStateName == "") { + this.stateGenerator(); + } + if(actStateName){ + var dis = Math.floor(Math.random() * stateList[actStateName]); + actDistName = stateDist[actStateName][dis] + } + return actDistName; + } + exports.distGenerator = distGenerator; + + /** + * This function generate address of an user. + * Dependent on the other functions + * @returns fullname,statename, districtname + */ + // Address of an user + function addressGenerator() { + if (actFullName == "") { + this.fullNameGenerator(); + } + if (actStateName == "") { + this.stateGenerator(); + } + if (actDistName == "") { + this.distGenerator(); + } + return [actFullName, actStateName, actDistName]; + } + exports.addressGenerator = addressGenerator; + + + //Financial Details + /** + * This function generate a virtual visa card Details + * @returns card holder name, card number, validThru, cvv + */ + function financialCardGenerator() { + if (actFullName == "") { + this.fullNameGenerator(); + } + var validMnth = Math.floor(Math.random() * 12); + var validYr = Math.floor(Math.random() * (2027 - 2022 + 1)) + 2022; + var cvv = Math.floor(Math.random() * (999 - 100 + 1)) + 100; + var visaElectronNum = Math.floor(Math.random() * (4999999999999999 - 4101110010111111 + 1)) + 4101110010111111; + var validThru = validMnth + "/" + validYr; + actCardFullDetails = [actFullName, visaElectronNum, validThru, cvv]; + return actCardFullDetails; + } + exports.financialCardGenerator = financialCardGenerator; + + /** + * This function gives you the bunch set of random address data + * in the form of array set. + * @param desiredDataSetNumber + * @returns bunchAddress + */ + function hugeAddressGenerator(desiredDataSetNumber) { + var bunchAddress = []; + for (let i = 0; i < desiredDataSetNumber; i++) { + actFullName = firstMaleName[Math.floor(Math.random() * 469)] + ' ' + title[Math.floor(Math.random() * 10)]; + state = this.stateGenerator(); + dist = this.distGenerator(); + bunchAddress.push([actFullName, state, dist]); + } + return bunchAddress; + } + exports.hugeAddressGenerator = hugeAddressGenerator; + /** + * This function gives you the bunch set of random biological data + * in the form of array set. + * @param desiredDataSetNumber + * @returns bunchBio + */ + function hugeBiologicalDataGenerator(desiredDataSetNumber) { + var bunchBio = []; + for (let i = 0; i < desiredDataSetNumber; i++) { + var fulName = firstMaleName[Math.floor(Math.random() * 469)] + ' ' + title[Math.floor(Math.random() * 10)]; + var gen = gender[Math.floor(Math.random() * 3)]; + var hairclr = hairColor[Math.floor(Math.random() * 4)]; + //var age = Math.floor(Math.random() * (99 - 18 + 1)) + 18; + var dob = this.birthDateTimeGenerator(); + var age = this.ageCalculation(); + var eyeclr = eyeColor[Math.floor(Math.random() * 7)]; + var bldGrp = bloodGroup[Math.floor(Math.random() * 8)]; + var weight = Math.floor(Math.random() * (109 - 35 + 1)) + 35; + var sknClr = skinColor[Math.floor(Math.random() * 25)]; + bunchBio.push([fulName, gen, hairclr, dob, age, eyeclr, bldGrp, weight, sknClr]); + } + return bunchBio; + } + exports.hugeBiologicalDataGenerator = hugeBiologicalDataGenerator; + \ No newline at end of file diff --git a/package/package.json b/package/package.json index 3656704..c4bf286 100644 --- a/package/package.json +++ b/package/package.json @@ -1,6 +1,6 @@ { "name": "pirated-data", - "version": "1.0.7", + "version": "2.0.0", "description": "Generating sample user data like name, age, mobilenumber, aadharnumber etc for testing.", "main": "index.js", "scripts": { diff --git a/package/readme.md b/package/readme.md index 53b792a..6f2f783 100644 --- a/package/readme.md +++ b/package/readme.md @@ -7,6 +7,7 @@

Pirated-Data

+ ![CodeFactor](https://www.codefactor.io/repository/github/satya319/pirated-data/badge/main) **Install the package via npm** @@ -24,6 +25,8 @@ npm i pirated-data - [User Id](#User-Id) - [Password](#Password) - [PanCard ID](#PanCard-ID) +- [Passport Number](#Passport-Number) +- [Driving license number](#Driving-license-number) - [Financial card](#Financial-card) - [Card Number](#Card-Number) - [Card Holder Name](#Card-Holder-Name) @@ -78,9 +81,6 @@ var card = userData.financialCardGenerator(); const userData = require('pirated-data'); var bnkName = userData.bankNameGenerator(); - - - // For getting AadharCard number const userData = require('pirated-data'); var aadhar = userData.aadharNumberGenerator(); @@ -104,6 +104,14 @@ var pwd = userData.password(10); var id = userData.panCardId(); console.log(id); +/*For getting passport number */ + const passNum = userData.passportNumber(); + console.log(passNum); + +/*For getting DL number */ +const dl = userData.drivinglicenseGenerator(); +console.log(dl); + /* For generating Gendor of an user */ const userData = require('pirated-data'); var gender = userData.genderGenerator(); diff --git a/test-folder/.gitignore b/test-folder/.gitignore new file mode 100644 index 0000000..ba62d06 --- /dev/null +++ b/test-folder/.gitignore @@ -0,0 +1,4 @@ +/node_modules +copyed.js +data.js + diff --git a/test-folder/script.mjs b/test-folder/script.mjs index d291ea7..1c21f77 100644 --- a/test-folder/script.mjs +++ b/test-folder/script.mjs @@ -1,61 +1,64 @@ -import userData from '../../pirated-data/package/index.js'; +import userData from '../../pirated-data/package/copyed.js'; // const userData = require('pirated-data'); // var result = userData.add(4,5) // console.log(result); -var startname = userData.firstNameGenerator(); -console.log("First name: "+startname); -var lastName =userData.lastNameGenerator(); -console.log("Last name: "+lastName); -var fulName = userData.fullNameGenerator(); -console.log(fulName); -var age = userData.adultAgeGenerator(); -console.log("Age: "+age); -var mobnum = userData.mobileNumberGenerator(); -console.log("Mobile number of user: "+mobnum); -var aadhar = userData.aadharNumberGenerator(); -console.log("Aaadhar number: "+aadhar); -var eml = userData.emailIdGenerator(); -console.log("Email id: "+eml); -var usrId = userData.userIdGenerator(); -console.log("Userid of user: "+usrId); -var pwd = userData.passwordGenerator(10); -console.log("Password of the user: "+pwd); -var gender = userData.genderGenerator(); -console.log("Gender of the user:"+gender); -var hrclr = userData.hairColorGenerator(); -console.log("user hair color is: "+hrclr); -var eyeclr = userData.eyeColorGenerator(); -console.log("eye color of a user is: ", eyeclr); -var bldgrp = userData.bloodGroupGenerator(); -console.log("blood group is: ",bldgrp); -var wt = userData.weightGenerator(); -console.log("weight of a user is: ",wt) -var biology = userData.BiologicalData(); -console.log(biology); -// var bnkName = userData.bankNameGenerator(); -// console.log("Bank name of user: "+bnkName); +// var startname = userData.firstNameGenerator(); +// console.log("First name: "+startname); +// var lastName =userData.lastNameGenerator(); +// console.log("Last name: "+lastName); +// var fulName = userData.fullNameGenerator(); +// console.log(fulName); +// var age = userData.adultAgeGenerator(); +// console.log("Age: "+age); +// var mobnum = userData.mobileNumberGenerator(); +// console.log("Mobile number of user: "+mobnum); +// var aadhar = userData.aadharNumberGenerator(); +// console.log("Aaadhar number: "+aadhar); +// var eml = userData.emailIdGenerator(); +// console.log("Email id: "+eml); +// var usrId = userData.userIdGenerator(); +// console.log("Userid of user: "+usrId); +// var pwd = userData.passwordGenerator(10); +// console.log("Password of the user: "+pwd); +// var gender = userData.genderGenerator(); +// console.log("Gender of the user:"+gender); +// var hrclr = userData.hairColorGenerator(); +// console.log("user hair color is: "+hrclr); +// var eyeclr = userData.eyeColorGenerator(); +// console.log("eye color of a user is: ", eyeclr); +// var bldgrp = userData.bloodGroupGenerator(); +// console.log("blood group is: ",bldgrp); +// var wt = userData.weightGenerator(); +// console.log("weight of a user is: ",wt) +// var biology = userData.BiologicalData(); +// console.log(biology); +// // var bnkName = userData.bankNameGenerator(); +// // console.log("Bank name of user: "+bnkName); var state = userData.stateGenerator(); console.log("State name is: "+state); -var dist = userData.distGenerator(); -console.log(dist); -var address = userData.addressGenerator(); -console.log(address); -var card = userData.financialCardGenerator(); -console.log("Card number: "+card); -// var bkfstnme = userData.breakastGenerator(); -// console.log(bkfstnme); -// var lnchcrynme = userData.lunchCurryGenerator(); -// console.log(lnchcrynme); - var bnchAddress = userData.hugeAddressGenerator(50); -console.log(bnchAddress); +// var dist = userData.distGenerator(); +// console.log(dist); +// var address = userData.addressGenerator(); +// console.log(address); +// var card = userData.financialCardGenerator(); +// console.log("Card number: "+card); +// // var bkfstnme = userData.breakastGenerator(); +// // console.log(bkfstnme); +// // var lnchcrynme = userData.lunchCurryGenerator(); +// // console.log(lnchcrynme); +// var bnchAddress = userData.hugeAddressGenerator(50); +// console.log(bnchAddress); -var bnchBio = userData.hugeBiologicalDataGenerator(10); -console.log(bnchBio); -var id = userData.panCardId(); -console.log(id); -// const d = userData.birthDateTimeGenerator( ); -// console.log(d); +// var bnchBio = userData.hugeBiologicalDataGenerator(10); +// console.log(bnchBio); +// var id = userData.panCardId(); +// console.log(id); +// // const d = userData.birthDateTimeGenerator( ); +// // console.log(d); // const age = userData.ageCalculation(); // console.log(age); -// console.log(add); +// const passNum = userData.passportNumber(); +// console.log(passNum); +const dl = userData.drivinglicenseGenerator(); +console.log(dl);