{"id":19071903,"url":"https://github.com/cyansalt/font-cloak","last_synced_at":"2026-02-22T18:03:26.325Z","repository":{"id":57239773,"uuid":"417370877","full_name":"CyanSalt/font-cloak","owner":"CyanSalt","description":"Encrypt your data with random fonts","archived":false,"fork":false,"pushed_at":"2024-05-22T03:31:56.000Z","size":1461,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-01T06:18:38.087Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CyanSalt.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-15T04:44:18.000Z","updated_at":"2024-05-22T03:32:00.000Z","dependencies_parsed_at":"2023-12-07T14:43:15.881Z","dependency_job_id":null,"html_url":"https://github.com/CyanSalt/font-cloak","commit_stats":{"total_commits":27,"total_committers":1,"mean_commits":27.0,"dds":0.0,"last_synced_commit":"8fa28184a4a4b7f1d8df08af1c2d5521a8e0ff78"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanSalt%2Ffont-cloak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanSalt%2Ffont-cloak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanSalt%2Ffont-cloak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyanSalt%2Ffont-cloak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CyanSalt","download_url":"https://codeload.github.com/CyanSalt/font-cloak/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245036122,"owners_count":20550661,"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":[],"created_at":"2024-11-09T01:32:20.037Z","updated_at":"2026-02-22T18:03:26.311Z","avatar_url":"https://github.com/CyanSalt.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# font-cloak\n\n[![npm](https://img.shields.io/npm/v/font-cloak.svg)](https://www.npmjs.com/package/font-cloak)\n\nEncrypt your data with random fonts.\n\nMainly based on [font-carrier](https://github.com/purplebamboo/font-carrier).\n\n\u003e [!WARNING]\n\u003e Before using this package, make sure you are aware of the relevant legal risks. For example, [SIL 1.1](https://openfontlicense.org/open-font-license-official-text/) prohibits retaining the \"Reserved Font Name\" after modifying the font; the legal statements of some fonts (such as [Alibaba Puhuiti](https://www.yuque.com/yiguang-wkqc2/puhuiti/nus9wiinq4aeiegy)) do not allow users to modify or reorganize the fonts in the way used by this package.\n\u003e\n\u003eThis package is not responsible for any legal issues arising from font licensing.\n\n## Installation\n\n```shell\nnpm install font-cloak\n```\n\n## Usage\n\n```javascript\nconst { generateFont } = require('font-cloak')\n\nconst newFontBuffer = generateFont('/path/to/font.ttf', {\n  type: 'woff2',\n  seed: String(new Date()),\n})\n\nconst magicString = generateMagicString(seed)\n```\n\nAfter storing the `newFontBuffer` in a suitable file (e.g. `font-cloak.woff2`), the content you wish to encrypt can be encoded with the following runtime function with the `magicString`:\n\n```javascript\nconst { encode } = require('font-cloak/lib/runtime')\n\nencode('1920*1080', magicString)\n```\n\n### Integrations with bundlers\n\nUsually we use it like this:\n\n```css\n@font-face {\n  font-family: 'MyFontCloak';\n  font-weight: 300;\n  src: url('/path/to/font.ttf?cloak=woff2') format('woff2'),\n    url('/path/to/font.ttf?cloak=woff') format('woff');\n  /* for webpack@\u003e=5 */\n  src: url('/path/to/font.ttf?cloak=.woff2') format('woff2'),\n    url('/path/to/font.ttf?cloak=.woff') format('woff');\n}\n```\n\n```javascript\nconst { encode } = require('font-cloak/lib/runtime')\n\n// For eslint\n// /* global FONT_CLOAK_MAGIC_STRING */\n// Or for typescript\n// declare const FONT_CLOAK_MAGIC_STRING: string\n\nfunction encodeFontCloak(text) {\n  return encode(text, FONT_CLOAK_MAGIC_STRING)\n}\n\nconst element = document.createElement('p')\nelement.textContent = encodeFontCloak(MY_DATA)\nelement.style.fontFamily = 'MyFontCloak'\n```\n\nTo achieve these results, we can configure the bundler as:\n\n- Webpack: See [Webpack](./lib/webpack)\n  - Vue CLI: See [Vue CLI](./lib/vue-cli)\n- Rollup, Vite, etc.: See [PostCSS](./lib/postcss)\n\n## How it works\n\n`generateFont` will shuffle the characters within the font and places them in the [Private Use Areas Unicode block](https://en.wikipedia.org/wiki/Private_Use_Areas) to generate a new font; `generateMagicString` will save the random number information in a hexadecimal string.\n\n**Note**: Given the common use cases, the font mapping contains only the [Basic Latin Unicode block](https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)); the runtime functions will also handle the corresponding character set only.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyansalt%2Ffont-cloak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyansalt%2Ffont-cloak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyansalt%2Ffont-cloak/lists"}