1
+ [
2
+ {
3
+ "categoryName" : " Basics" ,
4
+ "snippets" : [
5
+ {
6
+ "title" : " Hello, World!" ,
7
+ "description" : " Prints Hello, World! to the terminal." ,
8
+ "code" : [
9
+ " public class Program {" ,
10
+ " public static void Main(string[] args) {" ,
11
+ " System.Console.WriteLine(\" Hello, World!\" );" ,
12
+ " }" ,
13
+ " }"
14
+ ],
15
+ "tags" : [" c#" , " printing" , " hello-world" , " utility" ],
16
+ "author" : " chaitanya-jvnm"
17
+ }
18
+ ]
19
+ },
20
+ {
21
+ "categoryName" : " String Manipulation" ,
22
+ "snippets" : [
23
+ {
24
+ "title" : " Capitalize String" ,
25
+ "description" : " Makes the first letter of a string uppercase." ,
26
+ "code" : [
27
+ " public static string Capitalize(string str) {" ,
28
+ " return str.Substring(0, 1).ToUpper() + str.Substring(1);" ,
29
+ " }"
30
+ ],
31
+ "tags" : [" c#" , " string" , " manipulation" , " capitalize" ],
32
+ "author" : " chaitanya-jvnm"
33
+ },
34
+ {
35
+ "title" : " Reverse String" ,
36
+ "description" : " Reverses the characters in a string." ,
37
+ "code" : [
38
+ " public static string ReverseString(string str) {" ,
39
+ " char[] charArray = str.ToCharArray();" ,
40
+ " Array.Reverse(charArray);" ,
41
+ " return new string(charArray);" ,
42
+ " }"
43
+ ],
44
+ "tags" : [" c#" , " string" , " reverse" , " utility" ],
45
+ "author" : " chaitanya-jvnm"
46
+ },
47
+ {
48
+ "title" : " Split String" ,
49
+ "description" : " Splits a string by a delimiter." ,
50
+ "code" : [
51
+ " public static string[] SplitString(string str, string delimiter) {" ,
52
+ " return str.Split(delimiter);" ,
53
+ " }"
54
+ ],
55
+ "tags" : [" c#" , " string" , " split" , " utility" ],
56
+ "author" : " chaitanya-jvnm"
57
+ }
58
+ ]
59
+ },
60
+ {
61
+ "categoryName" : " GUID Manipulation" ,
62
+ "snippets" : [
63
+ {
64
+ "title" : " Generate GUID" ,
65
+ "description" : " Generates a new GUID." ,
66
+ "code" : [
67
+ " public static string GenerateGuid() {" ,
68
+ " return Guid.NewGuid().ToString();" ,
69
+ " }"
70
+ ],
71
+ "tags" : [" c#" , " guid" , " generate" , " utility" ],
72
+ "author" : " chaitanya-jvnm"
73
+ },
74
+ {
75
+ "title" : " Check GUID" ,
76
+ "description" : " Checks if a string is a valid GUID." ,
77
+ "code" : [
78
+ " public static bool IsGuid(string str) {" ,
79
+ " return Guid.TryParse(str, out _);" ,
80
+ " }"
81
+ ],
82
+ "tags" : [" c#" , " guid" , " check" , " utility" ],
83
+ "author" : " chaitanya-jvnm"
84
+ },
85
+ {
86
+ "title" : " GUID to Byte Array" ,
87
+ "description" : " Converts a GUID to a byte array." ,
88
+ "code" : [
89
+ " public static byte[] GuidToByteArray(string guid) {" ,
90
+ " return new Guid(guid).ToByteArray();" ,
91
+ " }"
92
+ ],
93
+ "tags" : [" c#" , " guid" , " byte-array" , " utility" ],
94
+ "author" : " chaitanya-jvnm"
95
+ }
96
+ ]
97
+ },
98
+ {
99
+ "categoryName" : " JWT Manipulation" ,
100
+ "snippets" : [
101
+ {
102
+ "title" : " Generate JWT" ,
103
+ "description" : " Generates a new JWT." ,
104
+ "code" : [
105
+ " public static string GenerateJwt(string secret, string issuer, string audience, int expirationMinutes) {" ,
106
+ " var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secret));" ,
107
+ " var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);" ,
108
+ " var token = new JwtSecurityToken(issuer, audience, null, expires: DateTime.UtcNow.AddMinutes(expirationMinutes), signingCredentials: credentials);" ,
109
+ " return new JwtSecurityTokenHandler().WriteToken(token);" ,
110
+ " }"
111
+ ],
112
+ "tags" : [" c#" , " jwt" , " generate" , " utility" ],
113
+ "author" : " chaitanya-jvnm"
114
+ },
115
+ {
116
+ "title" : " Decode JWT" ,
117
+ "description" : " Decodes a JWT." ,
118
+ "code" : [
119
+ " public static string DecodeJwt(string token) {" ,
120
+ " return new JwtSecurityTokenHandler().ReadJwtToken(token).ToString();" ,
121
+ " }"
122
+ ],
123
+ "tags" : [" c#" , " jwt" , " decode" , " utility" ],
124
+ "author" : " chaitanya-jvnm"
125
+ },
126
+ {
127
+ "title" : " Validate JWT" ,
128
+ "description" : " Validates a JWT." ,
129
+ "code" : [
130
+ " public static bool ValidateJwt(string token, string secret) {" ,
131
+ " var tokenHandler = new JwtSecurityTokenHandler();" ,
132
+ " var validationParameters = new TokenValidationParameters {" ,
133
+ " ValidateIssuerSigningKey = true," ,
134
+ " IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secret))," ,
135
+ " ValidateIssuer = false," ,
136
+ " ValidateAudience = false" ,
137
+ " };" ,
138
+ " try {" ,
139
+ " tokenHandler.ValidateToken(token, validationParameters, out _);" ,
140
+ " return true;" ,
141
+ " }" ,
142
+ " catch {" ,
143
+ " return false;" ,
144
+ " }" ,
145
+ " }"
146
+ ],
147
+ "tags" : [" c#" , " jwt" , " validate" , " utility" ],
148
+ "author" : " chaitanya-jvnm"
149
+ }
150
+ ]
151
+ }
152
+ ]
0 commit comments