{"id":21022861,"url":"https://github.com/attla/data-token","last_synced_at":"2025-09-30T23:31:19.928Z","repository":{"id":46450036,"uuid":"513018159","full_name":"attla/data-token","owner":"attla","description":"🪅 Turn everything into a token: randomized or predictable","archived":false,"fork":false,"pushed_at":"2023-04-21T13:09:44.000Z","size":47,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-19T11:14:14.039Z","etag":null,"topics":["data-token","data-transformation","jwt","jwt-token","laravel","laravel-package","token","tokenization","tokenizer"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/attla.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2022-07-12T06:01:41.000Z","updated_at":"2022-08-07T02:24:56.000Z","dependencies_parsed_at":"2022-09-26T22:30:34.199Z","dependency_job_id":null,"html_url":"https://github.com/attla/data-token","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attla%2Fdata-token","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attla%2Fdata-token/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attla%2Fdata-token/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attla%2Fdata-token/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/attla","download_url":"https://codeload.github.com/attla/data-token/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234796467,"owners_count":18888113,"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":["data-token","data-transformation","jwt","jwt-token","laravel","laravel-package","token","tokenization","tokenizer"],"created_at":"2024-11-19T11:14:26.162Z","updated_at":"2025-09-30T23:31:19.633Z","avatar_url":"https://github.com/attla.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data Token\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-lightgrey.svg\" alt=\"License\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/attla/data-token\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/attla/data-token\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/attla/data-token\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/attla/data-token\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n🪅 Turn everything into a token: randomized or predictable.\n\n## Installation\n\n```bash\ncomposer require attla/data-token\n```\n\n## Usage\n\nCreating and managing a token\n\n```php\n\nuse Attla\\DataToken\\Facade as DataToken;\n\n// Create with facade\n$token = DataToken::secrete('your secret phrase');\n\n// Set the issuer claim\n$token-\u003eiss();\n\n// Set the expiration in minutes\n$token-\u003eexp(120);\n\n// Set payload of the token\n$token-\u003epayload($model);\n\n// Set the browser identifier on token\n$token-\u003ebwr();\n\n// Set user IP on the token\n$token-\u003eip();\n\n// Get the token\n$tokenEncoded = $token-\u003eencode();\n\n```\n\nDecoding the token\n\n```php\n\n// Get token value as associative array\n$tokenValue = DataToken::decode($tokenEncoded, true);\n\n// Aliases for decode a token\n$tokenValue = DataToken::fromString($tokenEncoded);\n$tokenValue = DataToken::parseString($tokenEncoded);\n$tokenValue = DataToken::parse($tokenEncoded);\n\n```\n\nOthers ways to make a token\n\n```php\n\n// Make a unique token from anything\n$id = DataToken::id(123);\n\n// Make always the same token\n$sid = DataToken::sid(123);\n\n// Make a strong token\n$sign = DataToken::sign(123);\n\n```\n\n### List of message methods\n\n| Method | Parameters | Description |\n|--|--|--|\n| ``encode()`` | - | Encode the token |\n| ``decode(data, assoc)`` | String, Boolean | Decode the token, will be return false if as invalid |\n| ``fromString(data, assoc)`` | String, Boolean | Alias for ``decode()`` |\n| ``parseString(data, assoc)`` | String, Boolean | Alias for ``decode()`` |\n| ``parse(data, assoc)`` | String, Boolean | Alias for ``decode()`` |\n| ``iss()`` | - | Define the token issuer claim |\n| ``exp(minutes)`` | Integer or CarbonInterface | Time to expire the token |\n| ``payload(content)`` | Mixed | Set the content of the token, that can be a model, array, object, or anything, but can't be false |\n| ``bwr()`` | - | Set the browser identifier to the token |\n| ``ip()`` | - | Set the IP address from user to the token |\n| ``body()`` | - | Alias for ``payload()`` |\n| ``same()`` | - | Make the token always the same |\n| ``sign(minutesExpiration)`` | Integer or CarbonInterface | Create a strong validation of the token |\n| ``id(data)`` | Mixed | Generate a unique identifier of anything |\n| ``sid(data)`` | - | Always generate the same identifier of anything |\n| ``getEntropy()`` | - | Get entropy of the token |\n\n## License\n\nThis package is licensed under the [MIT license](LICENSE) © [Octha](https://octha.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fattla%2Fdata-token","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fattla%2Fdata-token","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fattla%2Fdata-token/lists"}