GithubHelp home page GithubHelp logo

pratikg9 / nanoid Goto Github PK

View Code? Open in Web Editor NEW

This project forked from antiflasher/nanoid

0.0 0.0 0.0 10 KB

Secure, URL-friendly, flexible and unique string ID generator for Swift

License: MIT License

Swift 100.00%

nanoid's Introduction

Nano ID

Secure, URL-friendly, flexible and unique string ID generator for Swift. Swift realization of Nano ID

Instalation

Drag-n-drop NanoID.swift file into your project.

Usage

// Nano ID with default alphabet (0-9a-zA-Z_~) and length (21 chars)
let id = NanoID.new() // -> dtY0D_lLeJJjM~pogpcY9
        
// Nano ID with default alphabet and given length
let id = NanoID.new(12) // -> _xw7Sou69dSQ
        
// Nano ID with given alphabet and length
let id = NanoID.new(alphabet: .uppercasedLatinLetters, size: 15) // -> BFIXOAMLMKVSTYS
        
// Nano ID with preset custom parameters
let nanoID = NanoID(alphabet: .lowercasedLatinLetters,.numbers, size:10)
let idFirst = nanoID.new() // -> b08eochgzf
let idSecond = nanoID.new() // -> 80q1uxyf2p

Performance

Generation of 100,000 IDs of 0-9a-zA-Z_~ alphabet with length of 21 characters was tested.

On iPhone 5, iOS 10.3.3

Total time: 23.474965 secs (0.00023 sec per one ID)

On iPhone X, iOS 11.4

Total time: 1.631867 secs (0.00002 sec per one ID)

Variety

Among all 100,000 generated IDs the least used character occered 30,795 times. The most used character occured 31,650 times (2.7% bias)

nanoid's People

Contributors

antiflasher avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.