GithubHelp home page GithubHelp logo

c-cuid's Introduction

c-cuid

A C Port of the collision-resistant id generator cuid.

Features

This library provides all the four functions as the original cuid
char* cuid(char* buff) writes a new null terminated cuid into given buffer (buffer size must be atleast CUID_LENGTH which is 26 bytes in order to fit the cuid)
char* slug(char* buff) writes a new null terminated slug ranging from 7 to 10 characters long into given buffer (buffer size must be atleast SLUG_LENGTH which is 11 bytes in order to fit the slug)
_Bool isCuid(char* buff) checks if given buffer is a valid cuid (returns 1 if yes, 0 if no)
_Bool isSlug(char* buff) checks if given buffer is a valid slug (returns 1 if yes, 0 if no)

Usage

You could use the library as follows

#include <stdio.h>
#include "c-cuid.h"
int main(){
	char cuidTest[CUID_LENGTH];
	char slugTest[SLUG_LENGTH];
	cuid(cuidTest);
	slug(slugTest);
	printf("CUID: %s\nisCuid: %s\nSLUG: %d\nisSlug:%d\n", cuidTest, slugTest, isCuid(cuidTest), isSlug(slugTest));
	// output (for example):
	// CUID: clb411w4100003s4f6y437nbt
	// isCuid: 1
	// SLUG: 632434s4 
	// isSlug: 1
}

Testing

You could run the test.sh or the test.bat to test if the library will work on your device If there's an error in compilation or unintended behaviour make an issue, or a pull request if you know how to fix it

Planned features

  • Adjusting and Testing for macOS (i don't have a mac, so if you have one you could do that and do a pull request I will review it as soon as possible)

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.