|
21 | 21 | "categoryName": "Guid Utilities", |
22 | 22 | "snippets": [ |
23 | 23 | { |
24 | | - "title": "Hello, World!", |
| 24 | + "title": "Generate GUID", |
25 | 25 | "description": "Generates a new GUID", |
26 | 26 | "author": "chaitanya-jvnm", |
27 | 27 | "tags": [ |
|
34 | 34 | "code": "public static string GenerateGuid() {\n return Guid.NewGuid().ToString();\n}\n" |
35 | 35 | }, |
36 | 36 | { |
37 | | - "title": "Hello, World!", |
| 37 | + "title": "Validate GUID", |
38 | 38 | "description": "Checks if a string is a valid GUID.", |
39 | 39 | "author": "chaitanya-jvnm", |
40 | 40 | "tags": [ |
|
52 | 52 | "categoryName": "Jwt Utilities", |
53 | 53 | "snippets": [ |
54 | 54 | { |
55 | | - "title": "Hello, World!", |
| 55 | + "title": "Decode JWT", |
56 | 56 | "description": "Decodes a JWT.", |
57 | 57 | "author": "chaitanya-jvnm", |
58 | 58 | "tags": [ |
|
65 | 65 | "code": "/// <summary>\n/// Decodes the JWT\n/// <summary>\npublic static string DecodeJwt(string token) {\n return new JwtSecurityTokenHandler().ReadJwtToken(token).ToString();\n}\n\n//Example\nstring token = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\";\n\nstring decodedJwt = DecodeJwt(token);\n\nConsole.WriteLine(decodedJwt); //Prints {\"alg\":\"HS256\",\"typ\":\"JWT\"}.{\"sub\":\"1234567890\",\"name\":\"John Doe\",\"iat\":1516239022}\n" |
66 | 66 | }, |
67 | 67 | { |
68 | | - "title": "Hello, World!", |
| 68 | + "title": "Generate JWT", |
69 | 69 | "description": "Generates a new JWT.", |
70 | 70 | "author": "chaitanya-jvnm", |
71 | 71 | "tags": [ |
|
78 | 78 | "code": "public static string GenerateJwt(string secret, string issuer, string audience, int expirationMinutes) {\n var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secret));\n var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);\n var token = new JwtSecurityToken(issuer, audience, null, expires: DateTime.UtcNow.AddMinutes(expirationMinutes), signingCredentials: credentials);\n return new JwtSecurityTokenHandler().WriteToken(token);\n}\n" |
79 | 79 | }, |
80 | 80 | { |
81 | | - "title": "Hello, World!", |
| 81 | + "title": "Validate JWT", |
82 | 82 | "description": "Validates a JWT.", |
83 | 83 | "author": "chaitanya-jvnm", |
84 | 84 | "tags": [ |
|
114 | 114 | "categoryName": "String Utilities", |
115 | 115 | "snippets": [ |
116 | 116 | { |
117 | | - "title": "Hello, World!", |
| 117 | + "title": "Capitalize first letter", |
118 | 118 | "description": "Makes the first letter of a string uppercase.", |
119 | 119 | "author": "chaitanya-jvnm", |
120 | 120 | "tags": [ |
|
0 commit comments