title: IDX10603: The algorithm: 'HS256' requires the SecurityKey.KeySize to be greater than '128' bits. KeySize reported: '32'. Parameter name: key.KeySize
body: <p>I was just working with Asp.Net Core Web API, and implementing Authentication. And I am calling this API from an Angular Application. But I am always getting an error as below.</p>
  
  <blockquote>
    <p>IDX10603: The algorithm: 'HS256' requires the SecurityKey.KeySize to be greater than '128' bits. KeySize reported: '32'. Parameter name: key.KeySize</p>
  </blockquote>
  
  <p>Below is my code for <code>ConfigureServices</code> in <strong>Startup.cs</strong> file. </p>
  
  <pre><code>public IServiceProvider ConfigureServices(IServiceCollection services)
              {
                  services.AddDbContext&lt;APIContext&gt;(option =&gt; option.UseInMemoryDatabase("AngularApp"));
  
                  services.AddCors(options =&gt; options.AddPolicy("Cors", builder =&gt;
                  {
                      builder.AllowAnyOrigin().
                      AllowAnyMethod().
                      AllowAnyHeader();
                  }
                  ));
  
                  var signinKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("Secret phase"));
  
                  services.AddAuthentication(options =&gt;
                  {
                      options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                      options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
                  }).AddJwtBearer(cfg =&gt;
                  {
                      cfg.RequireHttpsMetadata = false;
                      cfg.SaveToken = true;
                      cfg.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters()
                      {
                          IssuerSigningKey = signinKey,
                          ValidateAudience = false,
                          ValidateIssuer = false,
                          ValidateLifetime = false,
                          ValidateIssuerSigningKey = true,
                          ValidateActor = false,
                          ClockSkew = TimeSpan.Zero
                      };
                  });
                  services.AddMvc();
  
                  var serviceProvider = services.BuildServiceProvider();
                  return serviceProvider;
              }
  </code></pre>
  
  <p>And I am using <code>JwtPackage</code>in my controller as follows.</p>
  
  <pre><code>JwtPackage CreateJwtToken(User usr)
          {
              var signinKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("this is my custom Secret key for authnetication"));
              var signInCredentials = new SigningCredentials(signinKey, SecurityAlgorithms.HmacSha256);
              var claims = new Claim[] {
                  new Claim(JwtRegisteredClaimNames.Sub,usr.Id)
              };
              var jwt = new JwtSecurityToken(claims: claims, signingCredentials: signInCredentials);
              var encodedJwt = new JwtSecurityTokenHandler().WriteToken(jwt);
              return new JwtPackage() { FirstName = usr.FirstName, Token = encodedJwt };
          }
  </code></pre>
  
  <p>Can you please help me to fix this issue? Thank you.</p>