{"id":25635966,"url":"https://github.com/lemonce/svg-captcha","last_synced_at":"2025-02-23T00:02:00.239Z","repository":{"id":8397957,"uuid":"58204059","full_name":"produck/svg-captcha","owner":"produck","description":"generate svg captcha in node","archived":false,"fork":false,"pushed_at":"2024-02-04T23:20:25.000Z","size":1159,"stargazers_count":1860,"open_issues_count":23,"forks_count":174,"subscribers_count":24,"default_branch":"1.x","last_synced_at":"2024-10-29T17:56:09.064Z","etag":null,"topics":["captcha","captcha-alternative","captcha-generator","nodejs-captcha","svg-captcha"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/produck.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"code-of-conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-06T11:55:26.000Z","updated_at":"2024-10-25T17:27:46.000Z","dependencies_parsed_at":"2024-05-06T04:49:44.404Z","dependency_job_id":null,"html_url":"https://github.com/produck/svg-captcha","commit_stats":{"total_commits":64,"total_committers":6,"mean_commits":"10.666666666666666","dds":0.125,"last_synced_commit":"eb2e1dd4f8f93e902d41c6256382b3dffa171ece"},"previous_names":["steambap/svg-captcha","lemonce/svg-captcha"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/produck%2Fsvg-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/produck%2Fsvg-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/produck%2Fsvg-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/produck%2Fsvg-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/produck","download_url":"https://codeload.github.com/produck/svg-captcha/tar.gz/refs/heads/1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240250363,"owners_count":19771780,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["captcha","captcha-alternative","captcha-generator","nodejs-captcha","svg-captcha"],"created_at":"2025-02-23T00:01:52.388Z","updated_at":"2025-02-23T00:02:00.198Z","avatar_url":"https://github.com/produck.png","language":"JavaScript","funding_links":[],"categories":["验证码生成工具","Generowanie","graphic (图形库)","Code"],"sub_categories":["library/repositories"],"readme":"![svg-captcha](media/header.png)\n\n\u003cdiv align=\"center\"\u003e\n\n[![Build Status](https://img.shields.io/travis/lemonce/svg-captcha/master.svg?style=flat-square)](https://travis-ci.org/lemonce/svg-captcha)\n[![NPM Version](https://img.shields.io/npm/v/svg-captcha.svg?style=flat-square)](https://www.npmjs.com/package/svg-captcha)\n[![NPM Downloads](https://img.shields.io/npm/dm/svg-captcha.svg?style=flat-square)](https://www.npmjs.com/package/svg-captcha)\n\n\u003c/div\u003e\n\n\u003e generate svg captcha in node.js\n\n## Translations\n[中文](README_CN.md)\n\n## useful if you\n\n- cannot or do not want to use google recaptcha\n- have issue with install c++ addon\n\n## install\n```\nnpm install --save svg-captcha\n```\n\n## usage\n```Javascript\nvar svgCaptcha = require('svg-captcha');\n\nvar captcha = svgCaptcha.create();\nconsole.log(captcha);\n// {data: '\u003csvg.../svg\u003e', text: 'abcd'}\n```\nwith express\n```Javascript\nvar svgCaptcha = require('svg-captcha');\n\napp.get('/captcha', function (req, res) {\n\tvar captcha = svgCaptcha.create();\n\treq.session.captcha = captcha.text;\n\t\n\tres.type('svg');\n\tres.status(200).send(captcha.data);\n});\n```\n\n## API\n\n#### `svgCaptcha.create(options)`  \nIf no option is passed, you will get a random string of four characters and corresponding svg.  \n  \n* `size`: 4 // size of random string  \n* `ignoreChars`: '0o1i' // filter out some characters like 0o1i  \n* `noise`: 1 // number of noise lines  \n* `color`: true // characters will have distinct colors instead of grey, true if background option is set  \n* `background`: '#cc9966' // background color of the svg image  \n\nThis function returns an object that has the following property:\n* `data`: string // svg path data\n* `text`: string // captcha text\n\n#### `svgCaptcha.createMathExpr(options)`  \nSimilar to create api, you have the above options plus 3 additional:\n* `mathMin`: 1 // the minimum value the math expression can be\n* `mathMax`: 9 // the maximum value the math expression can be\n* `mathOperator`: + // The operator to use, `+`, `-` or `+-` (for random `+` or `-`)\n\nThis function returns an object that has the following property:\n* `data`: string // svg of the math expression\n* `text`: string // the answer of the math expression\n\n#### `svgCaptcha.loadFont(url)`\nLoad your own font and override the default font.\n* `url`: string // path to your font\nThis api is a wrapper around loadFont api of opentype.js.  \nYour may need experiment around various options to make your own font accessible.  \nSee the following api.\n\n#### `svgCaptcha.options`\nGain access to global setting object. \nIt is used for create and createMathExpr api as the default options.  \n  \nIn addition to size, noise, color, and background, you can also set the following property:\n* `width`: number // width of captcha\n* `height`: number // height of captcha\n* `fontSize`: number // captcha text size\n* `charPreset`: string // random character preset\n\n#### `svgCaptcha.randomText([size|options])`  \nreturn a random string.\n#### `svgCaptcha(text, options)`\nreturn a svg captcha based on text provided.  \n\nIn pre 1.1.0 version you have to call these two functions,  \nnow you can call create() to save some key strokes ;).\n\n## sample image\ndefault captcha image:\n\n![image](media/example.png)\n\nmath expression image with color options:\n\n![image2](media/example-2.png)\n\n## why use svg?\n\nIt does not require any c++ addon.  \nThe result image is smaller than jpeg image.\n\n\u003e This has to be a joke. /\\\u003ctext.+\\\u003e;.+\\\u003c\\/text\\\u003e/g.test...\n\nsvg captcha uses opentype.js underneath, which means that there is no\n'\u0026lt;text\u0026gt;1234\u0026lt;/text\u0026gt;'.  \nYou get\n'\u0026lt;path fill=\"#444\" d=\"M104.83 19.74L107.85 19.74L112 33.56L116.13 19.74L119.15 19.74L113.48 36.85...'  \ninstead.  \n  \nEven though you can write a program that convert svg to png, svg captcha has done its job  \n—— make captcha recognition harder\n\n## License\n[MIT](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemonce%2Fsvg-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemonce%2Fsvg-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemonce%2Fsvg-captcha/lists"}