Snippets Collections
npm install @prisma/client @auth/prisma-adapter
npm install prisma --save-dev
<script>
jQuery(function($){
$(document).on('click','.elementor-location-popup a', function(event){
elementorProFrontend.modules.popup.closePopup( {}, event);
});
});
</script>
//Code for Banking.java

import java.util.Scanner;
public class Banking{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		BankAccount newAccount =  new BankAccount();
		
		System.out.println("Enter Account Holder's Name :");
		newAccount.name = input.nextLine();
		
		System.out.print("Enter Initial Balance : Rs ");
		newAccount.balance = input.nextInt();
		
		System.out.println("Pick the Services Services:\n1)SMS Alerts\n2)Debit Card\n3)Both\n4)None");
		int pick = input.nextInt();
		
		switch(pick){
			case 1:
				newAccount.smsAlert = true;
				newAccount.debitCard = false;
			break;
			case 2:
				newAccount.smsAlert = false;
				newAccount.debitCard = true;
			break;
			case 3:
				newAccount.smsAlert = true;
				newAccount.debitCard = true;
			break;
			case 4:
				newAccount.smsAlert = false;
				newAccount.debitCard = false;
			break;
			default:
			System.out.println("Invalid Input");
		}
		
		newAccount.accountBehaviour();
		System.out.println("After deducting annual fees, the account information is as follows:");
        newAccount.displayAccountInfo();		
	}
}


///////////////////////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////////////////////


public class BankAccount{
	String name;
	double balance;
	boolean smsAlert=false;
	boolean debitCard=false;
	
	public void accountBehaviour(){
		int smsAlertFee=2000;
		int debitCardFee =5000;
		if(this.balance>=3000000){
			 System.out.println("No annual fees for PREMIUM account holders.");
                return;
		}
		 if (smsAlert) {
                this.balance -= smsAlertFee;
                System.out.println("Annual fee deducted for SMS Alerts: Rs" + smsAlertFee);
            }

        if (debitCard) {
            this.balance -= debitCardFee;
            System.out.println("Annual fee deducted for Debit Card: Rs" + debitCardFee);
        }
	}
	
	 public void displayAccountInfo() {
        System.out.println("Account Holder: " + name);
        System.out.println("Balance: Rs" + balance);
        System.out.println("SMS Alerts: " + (smsAlert ? "Subscribed" : "Not Subscribed"));
        System.out.println("Debit Card: " + (debitCard ? "Subscribed" : "Not Subscribed"));
    }	
}
//Code for bankAcoount.java

import java.util.Scanner;
public class bankAccount{
	public static void main (String[] args){
		Scanner input =new Scanner(System.in);
		accountDetails Account = new accountDetails();
		
		int choice;
		
		do{
			System.out.println("\nPress 1: To Deposit an amount\nPress 2: To Withdraw an amount\nPress 3: To View the current balance\nPress 4: To Close this program");
			choice = input.nextInt();
		switch(choice){
			case 1:
			System.out.print("Enter the amount you want to desposit in your account > ");
			double add= input.nextDouble();
			Account.accountHolder  = "mr saadis";
			Account.amountAdd(add);
			break;
			case 2:
				System.out.print("Enter the amount you want to Withdraw in your account > ");
				double minus= input.nextDouble();
				Account.amountMinus(minus);
			break;
			case 3:
				Account.checkBalance();
			break;
			case 4:
				Account.transactions();
			break;
			default:
				System.out.println("Invalid Choice");
		}
		
		  }while(choice!=4);
	}
}


///////////////////////////////////////////////////////////////////////////////////////////
//Code for accountDetails.java
///////////////////////////////////////////////////////////////////////////////////////////


import java.util.Scanner;
public class accountDetails {
	Scanner input =new Scanner(System.in);
	String accountHolder;
	double balance=0;
	int deposit=0;
	int withdraw=0;
	
	void checkBalance(){
		System.out.printf("%nAccount Title: %s%nBalance: %,.2f%n%n" ,this.accountHolder,this.balance);
	}
	void amountAdd(double add){
		if(this.balance>=100000){
			add += (add/100);
		}
		this.balance = this.balance + add;
		this.deposit++;
		System.out.print("Amount Deposite Successfuly\n");
	}
	
	void amountMinus(double minus){
		if(this.balance>0&&this.balance - minus>=0){
			if(this.balance<50000){
				System.out.print("Are you sure you want to withdraw? press 1 or 0: ");
				int chose= input.nextInt();
				if(chose==1){
					System.out.println("Your Balcance Before Transaction: "+ this.balance);
					minus += (2*minus)/100;
					this.balance = this.balance - minus;
					System.out.print("Amount Withdraw Successfuly\n");
					System.out.println("Your Balcance After Transaction: "+ this.balance);
					this.withdraw++;
				}
			}else{
				this.balance = this.balance - minus;
				System.out.print("Amount Withdraw Successfuly\n");
				this.withdraw++;
			}
			
		}else{
			System.out.print("Not enough Balance\n");
		}
	}
	
	
	void transactions(){
		System.out.printf("%nAccount Title: %s%nTotal Deposits: %d%nTotal Withdraws: %d%nBalance: %,.2f%n%n" ,this.accountHolder,this.deposit,this.withdraw,this.balance);
	}
	
}

// ================================
// Extra Footer
// ================================

add_action('ava_before_footer','extra_footer');
    function extra_footer() { ?>
       
<?php }
#include <iostream>
using namespace std;
int main()
{
    long long cnt=1, bef=0,befbef=0, sum=1, a, b;
    cin>>a;
    while(sum!=a)
    {
        befbef=bef;
        bef=cnt;
        cnt=bef+befbef;
        sum++;
    }
    b=cnt+cnt+bef;
    cout<<b*2;
}
#include <iostream>
using namespace std;
int main()
{
  int a, i, j, wei[200]{0}, hei[200]{0}, cnt=0;
  cin>>a;
  for(i=1;i<=a;i++)
  {
    cin>>wei[i]>>hei[i];
  }
  for(i=1;i<=a;i++)
  {
    for(j=1;j<=a;j++)
    {
      if(wei[i]<wei[j]&&hei[i]<hei[j])
      {
        cnt++;
      }
    }
    cout<<cnt+1<<" ";
    cnt=0;
  }
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  int arr[100][100]{0}, i, j, a, b, k, x, y, cnt=0;
  for(k=1;k<=4;k++)
  {
    cin>>a>>b>>x>>y;
    for(i=a;i<x;i++)
    {
      for(j=b;j<y;j++)
      {
        if(arr[j][i]==0)
        {
          arr[j][i]++;
          cnt++;
        }
      }
    }
  }
  cout<<cnt;
  return 0;
}
#include <iostream>
using namespace std;
int main()
{
  int arr[100][100]{0}, n, i, j ,k, x, y, cnt=0;
  cin>>n;
  for(k=1;k<=n;k++)
  {
    cin>>x>>y;
    for(i=0;i<=9;i++)
    {
      for(j=0;j<=9;j++)
      {
        if(arr[x+j][y+i]==0)
        {
          arr[x+j][y+i]++;
          cnt++;
        }
      }
    }
  }
  cout<<cnt;
  return 0;
}
#include <iostream>
using namespace std;
int main(){
    long long S, t=1, cnt=0, sum=0;    
    cin >> S;
    while(1){
        sum+=t;
        cnt++;
        if(sum>S){
            cnt--;
            break;
        }
        t++;
    }
    cout << cnt << "\n";
    return 0;
}
#include <iostream>
using namespace std;
int main()
{
    long long N, arr[500001], i, sp=1, sum=1;
    cin>>N;
    for(i=1;i<=N;i++)
    {
    cin>>arr[i];
    }
    for(i=N;i>1;i--)
    {
        if(arr[i-1]>sp)
        {
            sp++;
        }
        else
        {
            sp=arr[i-1];
        }
    sum+=sp;
    }
    cout<<sum;
}
#include <iostream>
#include <stack>
using namespace std;
int main()
{
    long long i, a, j, cnt=0;
    stack<int> st;
    cin>>a;
    for(i=1;i<=a;i++)
    {
        cin>>j;
        if(j!=0)
        {
            st.push(j);
            cnt+=j;
        }
        else
        {
            cnt-=st.top();
            st.pop();
        }
    }
    cout<<cnt;
}
#include<bits/stdc++.h>
using namespace std;
int a[2525], d[2525];

int main(){

    int n; cin >> n; for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++){
        int last = a[i];
        d[i] = max(d[i], d[i-1]);
        for(int j = i+1; j < n; j++){
            last = a[j]-last;
            if(last < 0) break;
            if(!last) d[j] = d[i-1]+1;
        }
    }
    cout << n-d[n-1];
}
#include <iostream>
using namespace std;
long long i, N, idx=0, sum=0, d=0, sw=0;
int main()
{
    cin>>N;
    for(i=1; i<=N; i++)
    {
        cin>>d;
        sum+=d;
        if(d!=0 && idx==0)
        {
            idx=i;
            sw=0;
        }
        else if(d==0 && idx!=0)
        {
            if(sw==0)
            {
                sum++;
                sw=1;
            }
            else
            {
                sw=0;
            }
        }
      else
      {
          sw=0;
      }
    }
    if(idx==0)
    {
          idx=N;
    }
    if(sw==0)
    {
        sum+=idx/2;
    }
    else
    {
        sum+=(idx-1)/2;
    }
    cout<<sum;
}
#include<iostream>
using namespace std;
int main()
{
    
}
      />  フ
      |  _  _ l
      /` ミ_xノ
     /      |
    /  ヽ   ノ
    │  | | |
 / ̄|   | | |
 | ( ̄ヽ__ヽ_)__)
 \二つ
READ MORE 
//Code for bankAccount.java

import java.util.Scanner;
public class bankAccount{
	public static void main (String[] args){
		Scanner input =new Scanner(System.in);
		accountDetails Account = new accountDetails();
		
		int choice;
		
		do{
			System.out.println("\nPress 1: To Deposit an amount\nPress 2: To Withdraw an amount\nPress 3: To View the current balance\nPress 4: To Close this program");
			choice = input.nextInt();
		switch(choice){
			case 1:
			System.out.print("Enter the amount you want to desposit in your account > ");
			double add= input.nextDouble();
			Account.accountHolder  = "mr saadis";
			Account.amountAdd(add);
			break;
			case 2:
				System.out.print("Enter the amount you want to Withdraw in your account > ");
				double minus= input.nextDouble();
				Account.amountMinus(minus);
			break;
			case 3:
				Account.checkBalance();
			break;
			case 4:
				Account.transactions();
			break;
			default:
				System.out.println("Invalid Choice");
		}
		
		  }while(choice!=4);
	}
}



///////////////////////////////////////////////////////////////////////////////////////////
//Code for accountDetails.java
///////////////////////////////////////////////////////////////////////////////////////////


public class accountDetails {
	String accountHolder;
	double balance=0;
	int deposit=0;
	int withdraw=0;
	
	void checkBalance(){
		System.out.printf("%nAccount Title: %s%nBalance: %,.2f%n%n" ,this.accountHolder,this.balance);
	}
	void amountAdd(double add){
		if(this.balance>=100000){
			add += (add/100);
		}
		this.balance = this.balance + add;
		this.deposit++;
		System.out.print("Amount Deposite Successfuly\n");
	}
	
	void amountMinus(double minus){
		if(this.balance>0&&this.balance - minus>=0){
			this.balance = this.balance - minus;
			System.out.print("Amount Withdraw Successfuly\n");
			this.withdraw++;
		}else{
			System.out.print("Not enough Balance\n");
		}
	}
	
	
	void transactions(){
		System.out.printf("%nAccount Title: %s%nTotal Deposits: %d%nTotal Withdraws: %d%nBalance: %,.2f%n%n" ,this.accountHolder,this.deposit,this.withdraw,this.balance);
	}
	
}
//Code for bankAccount.java

import java.util.Scanner;
public class bankAccount{
	public static void main (String[] args){
		Scanner input =new Scanner(System.in);
		accountDetails Account = new accountDetails();
		
		int choice;
		
		do{
			System.out.println("\nPress 1: To Deposit an amount\nPress 2: To Withdraw an amount\nPress 3: To View the current balance\nPress 4: To Close this program");
			choice = input.nextInt();
		switch(choice){
			case 1:
			System.out.print("Enter the amount you want to desposit in your account > ");
			double add= input.nextDouble();
			Account.accountHolder  = "mr saadis";
			Account.amountAdd(add);
			break;
			case 2:
				System.out.print("Enter the amount you want to Withdraw in your account > ");
				double minus= input.nextDouble();
				Account.amountMinus(minus);
			break;
			case 3:
				Account.checkBalance();
			break;
			case 4:
				Account.transactions();
			break;
			default:
				System.out.println("Invalid Choice");
		}
		
		  }while(choice!=4);
	}
}



///////////////////////////////////////////////////////////////////////////////////////////
//Code for accountDetails.java
///////////////////////////////////////////////////////////////////////////////////////////


public class accountDetails {
	String accountHolder;
	double balance=0;
	int deposit=0;
	int withdraw=0;
	
	void checkBalance(){
		System.out.printf("%nAccount Title: %s%nBalance: %,.2f%n%n" ,this.accountHolder,this.balance);
	}
	void amountAdd(double add){
		this.balance = this.balance + add;
		this.deposit++;
		System.out.print("Amount Deposite Successfuly\n");
	}
	
	void amountMinus(double minus){
		if(this.balance>0&&this.balance - minus>=0){
			this.balance = this.balance - minus;
			System.out.print("Amount Withdraw Successfuly\n");
			this.withdraw++;
		}else{
			System.out.print("Not enough Balance\n");
		}
	}
	
	
	void transactions(){
		System.out.printf("%nAccount Title: %s%nTotal Deposits: %d%nTotal Withdraws: %d%nBalance: %,.2f%n%n" ,this.accountHolder,this.deposit,this.withdraw,this.balance);
	}
	
}
//Code for bankAccount.java

import java.util.Scanner;
public class bankAccount{
	public static void main (String[] args){
		Scanner input =new Scanner(System.in);
		accountDetails Account = new accountDetails();
		int choice;
		do{
			System.out.println("\nPress 1: To Deposit an amount\nPress 2: To Withdraw an amount\nPress 3: To View the current balance\nPress 4: To Close this program");
			choice = input.nextInt();
		switch(choice){
			case 1:
			System.out.print("Enter the amount you want to desposit in your account > ");
			double add= input.nextDouble();
			Account.accountHolder  = "mr saadis";
			Account.amountAdd(add);
			break;
			case 2:
			System.out.print("Enter the amount you want to Withdraw in your account > ");
			double minus= input.nextDouble();
			Account.amountMinus(minus);
			break;
			case 3:
			Account.checkBalance();
			break;
		}	
		  }while(choice!=4);
	}
}



///////////////////////////////////////////////////////////////////////////////////////////
//Create accountDetails.java
///////////////////////////////////////////////////////////////////////////////////////////



public class accountDetails {
	String accountHolder;
	double balance=0;
	
	void checkBalance(){
		System.out.printf("%nAccount Title: %s%nBalance: %,.2f%n%n" ,this.accountHolder,this.balance);
	}
	void amountAdd(double add){
		this.balance = this.balance + add;
		System.out.print("Amount Deposite Successfuly\n");
	}
	
	void amountMinus(double minus){
		if(this.balance>0&&this.balance - minus>=0){
			this.balance = this.balance - minus;
			System.out.print("Amount Withdraw Successfuly\n");
		}else{
			System.out.print("Not enough Balance\n");
		}
	}	
}
import java.util.Scanner;

public class Task10{
	public static void main(String args[]){
		
		Scanner input = new Scanner(System.in);
		
		System.out.println("Enter total sale amount: ");
		double sale = input.nextDouble();
		
		double commission = 0;
		double bonus = 0; 
		double fixedSalary = 25000;
		
		if(sale <= 100000){
			commission = 0.02 * sale;
		}
		else if(sale > 100000 && sale < 300000){
			commission = 0.015 * sale;
			bonus = 2000;
		}
		else if(sale > 300000){
			commission = 0.01 * sale;
			bonus = 3000;
		}
		
		double totalSalary = fixedSalary + commission + bonus;
		
		System.out.printf("Total salary of employee is: %.2f",totalSalary);
		
		
	}
}
import java.util.Scanner;

public class Task9{
	public static void main(String args[]){
		
		Scanner input = new Scanner(System.in);
		
		System.out.println("Enter your basic salary: ");
		int basicSalary = input.nextInt();
		
		int houseRentAlowance = 0,medicalAllowance = 0;
		
		if(basicSalary < 10000){
			houseRentAlowance = (basicSalary * 50) / 100;
			medicalAllowance = (basicSalary * 10) / 100;
		}
		else if(basicSalary >= 10000 && basicSalary <= 20000){
			houseRentAlowance = (basicSalary * 60) / 100;
			medicalAllowance = (basicSalary * 15) / 100;
		}
		else if(basicSalary > 20000){
			houseRentAlowance = (basicSalary * 70) / 100;
			medicalAllowance = (basicSalary * 20) / 100;
		}
		
		int grossSalary = basicSalary + houseRentAlowance + medicalAllowance;
		
		System.out.printf("The gross salary is %d",grossSalary);
		
	}
}
import java.util.Scanner;

public class Task8{
	public static void main(String args[]){
		
		Scanner input = new Scanner(System.in);
		
		System.out.println("Enter end number: ");
		int endNo = input.nextInt();
		
		int count = 0;
		int i;
		String spNum = "Following are the special numbers: ";
		
		for(i = 1; i <= endNo; i++){
			if(i % 2 == 0 && i % 3 == 0 && i % 7 != 0){
				count++;
				spNum = spNum + i + ",";
			}
		}
		System.out.println("Special Number Count: "+ count);
		System.out.print(spNum);
	}
}
import java.util.Scanner;

public class Task7{
	public static void main(String args[]){
		Scanner input = new Scanner(System.in);
		
		System.out.println("Enter the age: ");
		int age = input.nextInt();
		System.out.println("Enter marks in maths: ");
		double mathMarks = input.nextDouble();
		System.out.println("Enter marks in english: ");
		double englishMarks = input.nextDouble();
		System.out.println("Enter marks in science: ");
		double scienceMarks = input.nextDouble();
		
		double totalMarks = mathMarks + englishMarks + scienceMarks;
		
		if(age > 15 && mathMarks >= 65 && englishMarks >= 55 && scienceMarks > 50 && totalMarks >= 180){
			System.out.println("Eligible for admission!");
		}
		else{
			System.out.println("Not eligible for admission");
		}
		
	}
}
public delegate T SampleGenericDelegate<T>();  
  
public static void Test()  
{  
    SampleGenericDelegate<String> dString = () => " ";  
  
    // You can assign the dObject delegate  
    // to the same lambda expression as dString delegate  
    // because of the variance support for
    // matching method signatures with delegate types.  
    SampleGenericDelegate<Object> dObject = () => " ";  
  
    // The following statement generates a compiler error  
    // because the generic type T is not marked as covariant.  
    // SampleGenericDelegate <Object> dObject = dString;  
  
}  
import java.util.Scanner;

public class Task10 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter sales amount: ");
        double sales = scanner.nextDouble();
        
       
        double fixedSalary = 25000;
       
        double commission;
        double bonus = 0;
        
        if (sales <= 100000) {
            commission = 0.02 * sales;
        } else if (sales > 100000 && sales < 300000) {
            commission = 0.015 * sales;
            bonus = 2000;
        } else {
            commission = 0.01 * sales;
            bonus = 3000;
        }
        double totalSalary = fixedSalary + commission + bonus;
        System.out.println("Total salary: " + totalSalary);
    }
}
import java.util.Scanner;

public class Task6{
	public static void main(String args[]){
		
		Scanner input = new Scanner(System.in);
		
		System.out.println("Enter first no: ");
		int num1 = input.nextInt();
		System.out.println("Enter second no: ");
		int num2 = input.nextInt();
		int reminder = num1 % num2;
		System.out.printf("The reminder is: %d\n",reminder);
		if(reminder == 0){
			System.out.printf("%d is divisible by %d",num1,num2);
		}
		else{
			System.out.printf("%d is not divisible by %d",num1,num2);
		}
		
	}
}
import java.util.Scanner;

public class Task5{
	public static void main(String args[]){
		
		Scanner input = new Scanner(System.in);
		
		System.out.println("Enter table #: ");
		int tableNo = input.nextInt();
		System.out.println("Enter start #: ");
		int startNo = input.nextInt();
		System.out.println("Enter end #: ");
		int endNo = input.nextInt();
		
		int i;
		for(i = startNo; i <= endNo; i++){
			System.out.printf("%d x %d = %d\n",i,tableNo,tableNo*i);
		}	
		
	}
}
import java.util.Scanner ;
public class Task9 {
	
	public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.print("Enter Basic Salary : ");
		double basicSalary = input.nextDouble();
		double houseRent=0,MedicalAllowance=0;
		
		if(basicSalary<10000){
			houseRent = (basicSalary*50)/100;
			MedicalAllowance = (basicSalary*10)/100;
		}else if(basicSalary>=10000&&basicSalary<=20000){
			houseRent = (basicSalary*60)/100;
			MedicalAllowance = (basicSalary*15)/100;
		}else if(basicSalary>20000){
			houseRent = (basicSalary*70)/100;
			MedicalAllowance = (basicSalary*20)/100;
		}
		
		double GrossSalary = basicSalary + houseRent + MedicalAllowance;
		
		System.out.printf("\n Gross Salary is %.2f",GrossSalary);
		
	}
}
import java.util.Scanner;
public class Abid {
	public static void main (String [] args){
		Scanner input = new Scanner(System.in);
		System.out.print("Enter End no. : ");
		int endNum = input.nextInt();
		int countSP=0;
		String spNum = "Following are special: ";
		
		for(int i=1; i<=endNum; i++){
			if (i%2==0&&i%3==0&&i%7!=0){
				countSP++;
				spNum = spNum + i +",";
			}
		}
		System.out.println("Special Number Count: "+countSP);
		System.out.println(spNum);		
	}
}
import java.util.Scanner;

public class Task4{
	
	public static void main(String[] args){
		
		Scanner input = new Scanner(System.in);
		int year;
		do{
		System.out.println("Enter a year: ");
		year = input.nextInt();
		}while(year < 500);	

		if(year % 100 == 0){
			if(year % 400 == 0 && year % 4 == 0){
				System.out.println("It is a century leap year! ");
			}else{
				System.out.println("It is not a leap year! ");
			}
		}
		    else if(year % 4 == 0){
				System.out.println("It is a leap year! ");
			}
			else{
				System.out.println("It is not a leap year! ");
			}
		}	
		
	}
	
}
	
import java.util.Scanner ;
public class Task7 {
	
	public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.print("Enter Applicant age : ");
		int age = input.nextInt();
		System.out.print("Enter Applicant Math Marks : ");
		int math = input.nextInt();
		System.out.print("Enter Applicant English Marks : ");
		int eng = input.nextInt();
		System.out.print("Enter Applicant Science Marks : ");
		int sci = input.nextInt();
		
		if(age>15&&math>=65&&eng>=65&&sci>50&&math+eng+sci>=180){
			System.out.println("\nEligible for Admission");
		}else{
			System.out.println("\nNot Eligible for Admission");
		}
		
	}
}
import java.util.Scanner;
public class Abid {
	public static void main (String [] args){
		Scanner input = new Scanner(System.in);
		System.out.print("Enter first no. : ");
		int num1 = input.nextInt();
		System.out.print("Enter second no.: ");
		int num2 = input.nextInt();
		int reminder = num1%num2;
		System.out.println("Reminder is: "+reminder);	
		if(reminder == 0){
			System.out.println(num1+" is Divisible by "+num2);			
		}else {
			System.out.println(num1+" is Not Divisible by "+num2);
		}
		
	}
}
import java.util.Scanner;

public class Task3{
	
	public static void main(String args[]){
		
		Scanner input = new Scanner(System.in);
		
		System.out.println("Enter a four digit number: ");
		int num = input.nextInt();
		
		if(num < 1000 || num < 9999){
			System.out.println("Please enter a valid 4 digit number! ");
		}
		
		
		
		int num4 = num % 10;
		int num3 = (num % 100) / 10;
		int num2 = (num % 1000) / 100;
		int num1 = num / 1000;
		
		System.out.println("The four digits are: ");
		System.out.println(num1);
		System.out.println(num2);
		System.out.println(num3);
		System.out.println(num4);
		
		
		 
	}  
	
	
}
	
import java.util.Scanner ;
public class Task5 {
	
	public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.print("Enter table #: ");
		int table = input.nextInt();
		System.out.print("Enter start #: ");
		int start = input.nextInt();
		System.out.print("Enter end #: ");
		int end = input.nextInt();
		tables(table,start,end);
	}
	
	public static void tables(int Table,int Start,int End){
		for(int i=Start; i<=End; i++){
			System.out.printf("%d * %d = %d%n",Table,i,i*Table);
		}
	}
	
	
}
import java.util.Scanner ;
public class Task4 {
	
	public static void main (String[] args) {
		Scanner input = new Scanner ( System.in ) ;
		int year =0;
		
	do{
		System.out.print ( "Enter year : ") ;	
		year = input.nextInt() ;
		
	}while (year<500);
	Leap(year);

	
	}
	
	public static void Leap (int year){
		if(year%100==0){
			if(year%400==0&&year%4==0){
				System.out.println ( "Century Leap year  ") ;
			}else{
				System.out.println ( "Not a Leap year  ") ;
			}
		}else{
			if(year%4==0){
				System.out.println ( "Leap year  ") ;
			}else{
				System.out.println ( "Not a Leap year  ") ;
			}
		}
		
	}
	
}

import java.util.Scanner;
public class Abid {
	public static void main (String [] args){
		Scanner input = new Scanner(System.in);
		System.out.print("Enter a 4 digit no. : ");
		int num = input.nextInt();
		int firstdigit = (num%10000)/1000;
		int seconddigit = (num%1000)/100;
		int thirdigit = (num%100)/10;
		int fourthdigit = (num%10)/1;
		
		System.out.println(firstdigit);
		System.out.println(seconddigit);
		System.out.println(thirdigit);
		System.out.println(fourthdigit);
		
	}
}
import java.util.Scanner;

public class Task1{
	
	public static void main(String args[]){
		int num;
		Scanner input = new Scanner(System.in);
		
		System.out.print("Enter a number: ");
		num = input.nextInt();
		
		
		boolean Num = true;
		for(int i = 2; i <= num; i++){
			Num = true;
			for(int j = 2; j < i; j++){
				if(i % j == 0){
					Num = false;
					break;
				}	
			}
			if(Num == true)
			System.out.println(i);
			
		}
				
			
	}
}
import java.util.Scanner;
public class Abid {
	public static void main (String [] args){
		Scanner input = new Scanner(System.in);
		System.out.print("Enter a Positive Integer : ");
		int num = input.nextInt();
		boolean NUM = true; 
		for (int i =2; i<=num ; i++ ){
			NUM = true;
			for(int j = 2; j< i; j++ ){
				if(i%j==0){
					NUM = false;
					break;
				}	
			}
			System.out.println(i+" "+NUM);
		}
	}
}
Zugriffs-Ebenen von Membern

Mit Zugriffsebenen gibt man an von welchen Stellen im Code auf Elemente zugegriffen werden kann.

Dient für die überschaubarkeit und sicherheit des Codes.

Public -> Keine Zugriffseinschränkung
Private -> Zugriff auf die Klasse beschränkt
Protected -> Zugriff auf Klasse und davon abgeleitete Typen beschränkt
Internal -> Zugriff auf die Assembly beschränkt
Protected Internal -> Zugriff auf die aktuelle Assembly oder die von der enthaltenen Klasse abgeleiteten Typen beschränkt

____________________________________________________________________________

Werte- und Referenztypen

Wertetypen sind die primitiven Datentypen (integer, float), Structs und Enums

Referenztypen sind Strings, Arrays und Klassen

Unterschied liegt in der Art und Weise wie die Werte gespeichert werden

Wertetypen -> Werden auf dem Stack gespeichert
Referenztypen -> Werden auf dem Heap gespeichert

Stack ist ein bereich des RAMs. Speicher ist sehr effizient und schnell

Heap ist ein nicht gut strukturierter bereich des RAMs, weniger effizient. Speicher muss wieder freigegeben werden wenn nicht mehr benötigt. Referenztypen belasten den Speicher mehr, muss vom Garbage-Collector freigegeben werden.

Wertetypen enthalten immer den tatsächlichen Wert

Referenztypen enthalten nur einen Zeiger/Pointer mit der Referenz auf das Objekt

____________________________________________________________________________

Konstruktor

Der Konstruktor ist die erste Methode die in einem Objekt aufgerufen wird

Er wird dazu verwendet Eigenschaften und Variablen zu initialisieren

Wird mit dem "new" Schlüsselwort eingeleitet, wird bei der erstellung eines Objekts aufgerufen

Person person1 = new Person();

Ihm können auch Parameter übergeben werden

Person person1 = new Person("Sabine", "Müller", 34);

Konstruktor Definition

Muss nicht selbst definiert werden, wenn man diesen nicht braucht. Es wird ein leerer Konstruktor automatisch erzeugt, sollte kein eigener definiert werden

class Person {
	//Eigenschaften
	public string Vorname {get; set;}
	public string Nachname {get; set;}
	public int Alter {get; set;}

	//Konstruktor
public Person(string vorname, string nachname, int alter){
  Vorname = vorname;
  Nachname = nachname;
  Alter = alter;
}
}

Schnittstellen/Interfaces

Eine Klasse, die eine Schnittstelle implementiert, muss alle vorgegebenen Member enthalten.

Eine Schnittstelle kann folgende Dinge vorschreiben:
-Methoden
-Eigenschaften
-Ereignisse (Events)
-Indexer

Die eigentliche Funktionalität der Member wird in der Klasse selbst codiert.

interface ITier
{
  //Eigenschaften
  int Alter {get; set;}
  string Geschlecht {get; set;}
  
  //Methoden
  void Essen();
  void Trinken();
}

class Löwe : ITier
{
  //Eigenschaften
  
  //Methoden
}

Abstrakte Klassen und Methoden

Eine abstrakte Klasse ist eine nicht instanziierbare Klasse, die nur dazu dient geerbt zu werden.

Schnittstellen können Member nur vorgeben, während abstrakte Klasse auch tatsächlichen Code enthalten können.

Man verwendet abstrakte Klassen auch als Basisklassen.


Polymorphismus

Statische Polymorphie
Mit der statischen Polymorphie ist das Überladen von Methoden gemeint.

Dynamische Polymorphie
Mit der dynamischen Polymorphie ist das Überschreiben von abstrakten Methoden gemeint. Hierfür kann auch das Schlüsselwort "virtual" verwendet werden.


Structs

Ein Struct-Typ ist ein Typ in C#, welcher dazu verwendet wird, zusammengehörende Variablen zu gruppieren, um somit kompakte Objekte darzustellen.

struct Point
{
  public int x;
  public int y;
}

Strukturen sind eine speicherfreundliche "Alternative" zu Klassen, da sie Wertetypen sind und somit auf dem Stack-Speicher verwaltet werden.
Ein Struct ist nicht dasselbe wie eine Klasse! (Klasse = Referenztyp, Struct = Wertetyp).


Enums

Mit Enums können wir unsere eigenen Datentypen definieren. Sie sind eine Sammlung aus Konstanten auf die man einzenln über den Enum zugreifen kann.

enum Himmelsrichtung 
{
    Nord = 0,
    Ost = 1,
    Süd = 2,
    West = 3
}

static void Main(string[] args)
{
  Himmelsrichtung richtung = Himmelsrichtung.Nord;
  Console.WriteLine(richtung); //OUTPUT: "Nord"
  Console.WriteLine((int)richtung); //OUTPUT: "0"
}


Collections

Collections sind Klassen, welche das Speichern von mehreren Werten on einem Objekt ermöglichen (ähnlich wie bei Arrays).
Sie sind flexibler als Arrays, da ihre Größe nicht beim Kompilieren feststehen muss.
-Arrays haben eine statische Grüße
-Collections haben eine dynamische Größe

-Lists - ähnelt dem Array am meisten, gleiche Funktion nur flexibler und dynamisch, Größe passt sich an.

//Erstelle die Liste
List<string> namensListe = new List<string>();

//Alternativ
List<string> namensListe = new List<string>()
{
    "Alina",
    "Hendrik",
    "Janek",
    "Isabell"
};

//Füge Werte zur Liste hinzu
namensListe.Add("Janek");
namensListe.Add("Hendrik");
namensListe.Add("Sandra");

//Werte löschen
namensListe.Remove("Janek");

//Index löschen
namensListe.RemoveAt(2);

//Lese die Werte per Schleife aus
foreach(string name in namensListe)
{
  Console.WriteLine(name);
}


Stacks

Stacks sind eine sehr einfache Art von Collection, welche man mit einem Stapel Karten vergleichen kann.

Stacks haben dabei 3 wichtige Methoden:
-Push() -> Zum Hinzufügen von Werten auf den Stapel.
-Pop() -> Gibt den obersten Wert auf dem Stapel zurück und löscht ihn dann.
-Peek() -> Gibt den obersten Wert auf dem Stapel zurück ohne ihn zu löschen.

Der oberste Wert auf dem Stapel ist immer der Wert, der zuletzt hinzugefügt wurde.

//Stack erstellen
Stack<int> numberStack = new Stack<int>();

//Werte hinzufügen
numberStack.Push(1);
numberStack.Push(2);
numberStack.Push(3);

//Obersten Wert lesen und löschen
Console.WriteLine(numberStack.Pop()); //OUTPUT: 3
Console.WriteLine(numberStack.Pop()); //OUTPUT: 2

//Obersten Wert lesen
Console.WriteLine(numberStack.Peek()); //OUTPUT: 1
Console.WriteLine(numberStack.Peek()); //OUTPUT: 1


Queues

Queues sind eine Datenstruktur welche man mit einer Warteschlange vergleichen kann.

Die Queue-Klasse enthält 3 wichtige Methoden:
-Enqueue() -> Zum hinzufügen eines Wertes zur Warteschlange.
-Dequeue() -> Zum lesen und löschen des ersten Wertes in der Warteschlange.
-Peek() -> Zum lesen des ersten Wertes ohne ihn zu löschen.

Beim lesen wird immer der Wert zurückgegeben der am frühesten hinzugefügt wurde!

//Queue erstellen
  Queue<string> personQueue new Queue<string>();

//Werte hinzufügen
personQueue.Enqueue("Peter");
personQueue.Enqueue("Alina");
personQueue.Enqueue("Sandra");
personQueue.Enqueue("Sabrina");

//Ersten Wert lesen und löschen
Console.WriteLine(personQueue.Dequeue()); //OUTPUT: Peter
Console.WriteLine(personQueue.Dequeue()); //OUTPUT: Alina
Console.WriteLine(personQueue.Dequeue());//OUTPUT: Sandra

//Ersten Wert lesen
Console.WriteLine(personQueue.Peek()); //OUTPUT: Sabrina
Console.WriteLine(personQueue.Peek()); //OUTPUT: Sabrina


Dictionaries

Dictionaries sind eine Datenstruktur, welche man mit einem Wörterbuch vergleichen kann.
Die Werte die darin gespeichert werden, bestehen aus einem Key und einem Value.
Key und Value können dabei von einem beliebigen Datentyp sein.

//Dictionary erstellen
Dictionary<int, string> kunden = new Dictionary<int, string>();

//Werte hinzufügen
kunden.Add(1000, "Sebastian");
kunden.Add(1001, "Alina");
kunden.Add(1002, "Franz");
kunden.Add(1003, "Peter");

//Werte löschen
kunden.Remove(1003);

//Zusätzliche Logik um Fehler bei Abfrage von Fehlerhaften Key Werten zu verhindern
if (kunden.ContainsKey(1003)){
  Console.WriteLine(kunden[1003]);
}

//Werte Lesen
Console.WriteLine(kunden[1002]); //OUTPUT: "Franz"

//Dictionaries mit Schleifen durchlaufen
foreach(KeyValuePair<int, string> kundenInfo in kunden)
{
  Console.WriteLine(kundenInfo.Key, kundenInfo.Value);
}


Generics

In der Programmierung dienen Variablen als Platzhalter für Werte.
Generics dienen als Platzhalter für Datentypen.
Generics kommen dann zum Einsatz, wenn man zum Zeitpunkt der Entwicklung noch nicht ganz genau weiß, welchen Datentypen man für eine Varible im Code verwenden möchte.

//Generic T erstellen
class Wertebehälter<T>
{
  //Eigenschaft vom typ "T" erstellen, dient als Platzhalter
  //Der Datentyp wird erst bei der Erstellung eines Objektes festgelegt
    public T MeinWert { get; set; }

    public Wertebehälter(T wert)
    {
        MeinWert = wert;
    }

    public void WertAusgabe()
    {
        Console.WriteLine(MeinWert.ToString());
    }
}

static void Main(string[] args)
{
  //Der Datentyp "string" wird dem Platzhalter zugewiesen
    Wertebehälter<string> behälter = new Wertebehälter<string>("Janek");
    behälter.WertAusgabe(); //OUTPUT: "Janek"
}


Delegaten

Ein Delegat ist ein Funktionszeiger.
Er stellt einen Typen dar, in welchen man die Referenz zu einer Methode speichern kann.
Delegaten ermöglichen also das Speichern von Methodenreferenzen in einer Variable, über welche man die Methode dann jederzeit aufrufen kann!
Bei der Definition des Delegaten wird der Rückgabetyp und die Methoden-Signatur angegeben.
Um eine Methode in einen Delegaten zu schreiben muss diese mit der Delegaten-Definition kompatibel sein.

//Delegaten definieren
public delegate double Rechenoperation(double x, double y);

//Methode erstellen die kompatibel ist mit der Definition der Delegate
static double Addition(double x, double y)
{
  return x+y;
}

//Methodenreferenz wird in die Delegate gespeichert
static void Main(string[] args)
{
  Rechenoperation rechenoperation = new Rechenoperation(Addition);
  double ergebnis = rechenoperation(10,5);
}

Man verwendet Delegaten dann, wenn zur Laufzeit entschieden werden muss, welche Methode ausgeführt werden soll.
Mit Delegaten kann man Methoden definieren, die andere Methoden als Parameter annehmen und intern aufrufen können.


Try-Catch

Mit Try-Catch kann man Fehler zur Laufzeit abfangen und auf diese reagieren.
Das Konstrukt besteht aus mindestens zwei zusammenhängenden Code-Blöcken.

In den Try Block kommt der Code hinein, der einen Fehler auslösen könnte.
In den Catch Block kommt der Code hinein, mit welchen auf einen eventuellen Fehler reagiert wird.

Im Catch Block können wichtige Daten noch abgespeichert werden oder es kann zurück zum Anfang der Fehlerauslösenden Operation gesprungen werden.

try
{
  int[] zahlen = new int[3];
  
  zahlen[0] = 0;
  zahlen[1] = 1;
  zahlen[2] = 2;
  zahlen[3] = 3;
}
catch (InddexOutOfRangeException ex)
  {
    Console.WriteLine(ex.Message);
    Console.WriteLine("Du hast zu viele Indizes befüllt!");
  }
catch (Exception ex)
  {
    Console.WriteLine(ex.Message);
  }

Die Exceptions müssen der Reihe nach immer allgemeiner werden.

Der Finally-Block kann als letzter Block an ein Try-Catch-Konstrukt angehängt werden.
Der sich im Finally-Block befindliche Code wird IMMER ausgelöst werden, egal ob eine Exception ausgelöst wurde oder nicht.
Er wird normalerweise dazu verwendet, um fremde Ressourcen vor dem Verlassen einer Methode wieder freizugeben(Datenbankverbindungen, Datenströme, usw...)

static void WriteToFile()
{
  try
    {
      //Schreibe auf eine Datei
    }
  catch (Exception ex)
    {
      //Speichere bereits gesammelte Daten
      //Informiere den User über den Fehler
      return; //Beende die Methode
    }
  finally
    {
      //Trenne die Verbingung zur Datei
      //Gebe die fremden Ressource wieder frei
    }
  //Schreibe Daten in eine Log-Datei
}


Math-Klasse

Häufig verwendete Methoden:
-Abs(x) -> "Absolute" Gibt einen Wert in positiv zurück.
-Sign(x) -> "Signum" Gibt entweder -1, 0 oder 1 zurück.
-Pow(x) -> "Power of X" Potenziert einen Wert.
-Sqrt(x) -> "Square Root" Quadratwurzel
-Round(x,y) -> Runden auf Nachkommastellen
-Ceiling(x) -> Aufrunden auf Ganzzahl
-Floor(x) -> Abrunden auf Ganzzahl

Die Math-Klasse stellt neben den Methoden auch zwei Konstanten zur Verfügung:
PI -> Das Verhältnis eines Kreisumfangs zum Durchmesser
E -> Die Basis des natürlichen Logarithmus


Random-Klasse

Ist eine Klasse, die das erzeugen von zufälligen Zahlen ermöglicht.

//Erzeuge Random Objekt
Random rnd = new Random();

//Generiere zufällige Zahl zwischen 1 und 3
int zahl = rnd.Next(1, 4);

//Gebe die Zahl aus
Console.WriteLine(zahl);

Die Klasse stellt 3 relevante Methoden für die Erzeugung von zufälligen Werten bereit:

Random.Next() -> Gibt eine zufällige Ganzzahl zurück oder eine Zufallszahl in einem Bereich
Random.NextBytes() -> Befüllt ein ByteArray mit Zufallszahlen
Random.NextDouble() -> Gibt eine zufällige Zahl von 0.0 bis 1.0 zurück


System.IO

Ist ein Namespace welcher Klassen für die Arbeit mit Dateien, Verzeichnissen und Datenströmen bereitstellt.
Sein Aufgabenbereich kann man in 2 Kategorien aufteilen:
1. Arbeit mit Dateien und Verzeichnissen
2. Datentransport mithilfe von Streams

Wichtige Klassen:
-Directory und DirectoryInfo -> Zum Arbeiten mit Verzeichnissen
-File und FileInfo -> Zum Arbeiten mit Dateien
-Path -> Zum Arbeiten mit Pfaden
-Stream, FileStream, StreamReader, StreamWriter -> Klassen für Datenströme

Directory/DirectoryInfo

Sie ermöglichen das Erstellen/Verschieben und Auflisten von Verzeichnissen.
Die Klassen haben Eigenschaften welche Informationen über das Verzeichnis enthalten.

Eigenschaften
Name -> Name des Verzeichnisses
FullName -> Voller Name (kompletter Pfad) des Verzeichnisses
CreationTime -> Zeitpunkt der Erstellung des Verzeichnisses
Exists -> Gibt an ob das Verzeichnis existiert

Methoden
Create() -> Erstellt ein Verzeichnis
CreateSubdirectory() -> Erstellt ein Unterverzeichnis
Delete() -> Löscht das Verzeichnis und seine Dateien/Unterverzeichnisse
GetDirectories() -> Gibt die Unterverzeichnisse des aktuellen Verzeichnisses zurück
GetFiles() -> Gibt eine Dateiliste des aktuellen Verzeichnisses zurück
Refresh() -> Aktualisiert den Zustand des Objekts


File/FileInfo

Sie stellen Eigenschaften und Methoden zum Erstellen, Kopieren, Löschen, Verschieben und Öffnen von Dateien bereit.

Eigenschaften
Attributes -> Ruft die Attribute der Datei ab (z.B) ReadOnly
Name -> Gibt den Namen der Datei zurück
FullName -> Gibt den ganzen Pfad der Datei zurück
Extension ->Gibt die Dateienendung zurück (.txt, .png, .mp3, usw)
Length -> Ruft die Größe in Byte ab
Exists -> Gibt an ob die Datei existiert

Methoden
Create -> Erstellt eine Datei
Delete() -> Löscht eine Datei unwiederruflich
AppendText() -> Erstellt einen Streamwriter, der der Datei einen Text anfügt
MoveTo() -> Zum verschieben oder umbenennen von Dateien
Encrypt() -> Verschlüsselt eine Datei
Decrypt() -> Entschlüsselt eine Datei

Steams
Ein Stream ermöglicht den Transport von Daten zu und von einer Datenquelle.

Zu diesen Datenquellen gehören z.B.:
-Dateien (FileStream)
-Der Speicher (MemoryStream)
-Ein Netzwerk (NetworkStream)

All diese Stream-Klassen erben von der Abstrakten Basisklasse "Stream".

Helfer Klassen:

Für die Arbeit mit Streams gibt es Helfer-Klassen, welche das Umwandeln der Bytes in andere Formate automatisch erledigen.

-StreamReader -> Zum lesen von Streams
-StreamWriter -> Zum schreiben auf Streams

Diese Klassen erzeugen automatisch einen FileStream mit dem gearbeitet wird. Es ist also nur die Erzeugung eines Objektes der Helferklassen nötig.




















frame*((360/(frame_end+1))/57.296)

// a = 360 / (timeline_length + 1)
// a = 57.296 * b
// b = a / 57.296
// x = frame * b
#include <stdio.h>
int main (void) {
    double Budget, Price;
    int NumberofBooks;
    scanf ("%lf %lf", &Budget, &Price);
    NumberofBooks = (int) (Budget/Price);/*if you remove the parentheses "budget" will become an integer first and the answer may be incorrect*/
    printf ("%d", NumberofBooks);
    return 0;
}
#include <stdio.h>
int main (void){
    int popCurrent, popProjectedint;
    double Projection, popProjected;
    scanf ("%d %lf", &popCurrent, &Projection);
    popProjected = popCurrent * Projection/100 + popCurrent;
    popProjectedint = (int) popProjected;
    printf ("%d", popProjectedint);
    return 0;
}
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Security.Cryptography;

namespace JwtWebApiTutorial.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class AuthController : ControllerBase
    {
        public static User user = new User();
        private readonly IConfiguration _configuration;
        private readonly IUserService _userService;

        public AuthController(IConfiguration configuration, IUserService userService)
        {
            _configuration = configuration;
            _userService = userService;
        }

        [HttpGet, Authorize]
        public ActionResult<string> GetMe()
        {
            var userName = _userService.GetMyName();
            return Ok(userName);
        }

        [HttpPost("register")]
        public async Task<ActionResult<User>> Register(UserDto request)
        {
            CreatePasswordHash(request.Password, out byte[] passwordHash, out byte[] passwordSalt);

            user.Username = request.Username;
            user.PasswordHash = passwordHash;
            user.PasswordSalt = passwordSalt;
            return Ok(user);
        }

        [HttpPost("login")]
        public async Task<ActionResult<string>> Login(UserDto request)
        {
            if (user.Username != request.Username)
            {
                return BadRequest("User not found.");
            }

            if (!VerifyPasswordHash(request.Password, user.PasswordHash, user.PasswordSalt))
            {
                return BadRequest("Wrong password.");
            }

            string token = CreateToken(user);

            var refreshToken = GenerateRefreshToken();
            SetRefreshToken(refreshToken);

            return Ok(token);
        }

        [HttpPost("refresh-token")]
        public async Task<ActionResult<string>> RefreshToken()
        {
            var refreshToken = Request.Cookies["refreshToken"];

            if (!user.RefreshToken.Equals(refreshToken))
            {
                return Unauthorized("Invalid Refresh Token.");
            }
            else if(user.TokenExpires < DateTime.Now)
            {
                return Unauthorized("Token expired.");
            }

            string token = CreateToken(user);
            var newRefreshToken = GenerateRefreshToken();
            SetRefreshToken(newRefreshToken);

            return Ok(token);
        }

        private RefreshToken GenerateRefreshToken()
        {
            var refreshToken = new RefreshToken
            {
                Token = Convert.ToBase64String(RandomNumberGenerator.GetBytes(64)),
                Expires = DateTime.Now.AddDays(7),
                Created = DateTime.Now
            };

            return refreshToken;
        }

        private void SetRefreshToken(RefreshToken newRefreshToken)
        {
            var cookieOptions = new CookieOptions
            {
                HttpOnly = true,
                Expires = newRefreshToken.Expires
            };
            Response.Cookies.Append("refreshToken", newRefreshToken.Token, cookieOptions);

            user.RefreshToken = newRefreshToken.Token;
            user.TokenCreated = newRefreshToken.Created;
            user.TokenExpires = newRefreshToken.Expires;
        }

        private string CreateToken(User user)
        {
            List<Claim> claims = new List<Claim>
            {
                new Claim(ClaimTypes.Name, user.Username),
                new Claim(ClaimTypes.Role, "Admin")
            };

            var key = new SymmetricSecurityKey(System.Text.Encoding.UTF8.GetBytes(
                _configuration.GetSection("AppSettings:Token").Value));

            var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha512Signature);

            var token = new JwtSecurityToken(
                claims: claims,
                expires: DateTime.Now.AddDays(1),
                signingCredentials: creds);

            var jwt = new JwtSecurityTokenHandler().WriteToken(token);

            return jwt;
        }

        private void CreatePasswordHash(string password, out byte[] passwordHash, out byte[] passwordSalt)
        {
            using (var hmac = new HMACSHA512())
            {
                passwordSalt = hmac.Key;
                passwordHash = hmac.ComputeHash(System.Text.Encoding.UTF8.GetBytes(password));
            }
        }

        private bool VerifyPasswordHash(string password, byte[] passwordHash, byte[] passwordSalt)
        {
            using (var hmac = new HMACSHA512(passwordSalt))
            {
                var computedHash = hmac.ComputeHash(System.Text.Encoding.UTF8.GetBytes(password));
                return computedHash.SequenceEqual(passwordHash);
            }
        }
    }
}
star

Sun Feb 25 2024 15:21:13 GMT+0000 (Coordinated Universal Time)

@abdullahalmamun #bash

star

Sun Feb 25 2024 15:20:52 GMT+0000 (Coordinated Universal Time)

@abdullahalmamun #bash

star

Sun Feb 25 2024 14:28:16 GMT+0000 (Coordinated Universal Time)

@abdullahalmamun #bash

star

Sun Feb 25 2024 14:07:12 GMT+0000 (Coordinated Universal Time)

@abdullahalmamun #bash

star

Sun Feb 25 2024 14:04:26 GMT+0000 (Coordinated Universal Time) https://authjs.dev/reference/adapter/prisma?_gl

@abdullahalmamun #bash

star

Sun Feb 25 2024 13:08:13 GMT+0000 (Coordinated Universal Time) https://react-hook-form.com/get-started

@abdullahalmamun #bash

star

Sun Feb 25 2024 12:30:33 GMT+0000 (Coordinated Universal Time)

@emalbert

star

Sun Feb 25 2024 12:22:13 GMT+0000 (Coordinated Universal Time)

@msaadshahid #java

star

Sun Feb 25 2024 10:43:56 GMT+0000 (Coordinated Universal Time)

@msaadshahid

star

Sun Feb 25 2024 10:34:37 GMT+0000 (Coordinated Universal Time)

@omnixima #php

star

Sun Feb 25 2024 07:43:34 GMT+0000 (Coordinated Universal Time) https://www.acmicpc.net/submit/13301/72858658

@hajinjang0714

star

Sun Feb 25 2024 07:43:10 GMT+0000 (Coordinated Universal Time) https://www.acmicpc.net/submit/7568/73555846

@hajinjang0714

star

Sun Feb 25 2024 07:42:51 GMT+0000 (Coordinated Universal Time) https://www.acmicpc.net/submit/2669/73559294

@hajinjang0714

star

Sun Feb 25 2024 07:39:50 GMT+0000 (Coordinated Universal Time) https://www.acmicpc.net/submit/2563/73557243

@hajinjang0714

star

Sun Feb 25 2024 07:39:28 GMT+0000 (Coordinated Universal Time) https://www.acmicpc.net/submit/1789/70564872

@hajinjang0714

star

Sun Feb 25 2024 07:38:59 GMT+0000 (Coordinated Universal Time) https://www.acmicpc.net/submit/28324/66992792

@hajinjang0714

star

Sun Feb 25 2024 07:38:25 GMT+0000 (Coordinated Universal Time) https://www.acmicpc.net/submit/10773/71653961

@hajinjang0714

star

Sun Feb 25 2024 07:37:44 GMT+0000 (Coordinated Universal Time) https://www.acmicpc.net/submit/25378/69222035

@hajinjang0714

star

Sun Feb 25 2024 07:21:08 GMT+0000 (Coordinated Universal Time) https://www.acmicpc.net/submit/28325/73975985

@hajinjang0714

star

Sun Feb 25 2024 07:10:19 GMT+0000 (Coordinated Universal Time)

@2late #excel

star

Sun Feb 25 2024 07:03:19 GMT+0000 (Coordinated Universal Time) https://www.onlinegdb.com/online_c++_compiler

@hajinjang0714

star

Sun Feb 25 2024 03:25:13 GMT+0000 (Coordinated Universal Time) https://store.steampowered.com/app/431960/Wallpaper_Engine/

@jak123

star

Sat Feb 24 2024 22:55:21 GMT+0000 (Coordinated Universal Time)

@msaadshahid

star

Sat Feb 24 2024 22:26:00 GMT+0000 (Coordinated Universal Time)

@msaadshahid

star

Sat Feb 24 2024 21:57:59 GMT+0000 (Coordinated Universal Time)

@msaadshahid

star

Sat Feb 24 2024 21:47:53 GMT+0000 (Coordinated Universal Time)

@abdul_rehman #java

star

Sat Feb 24 2024 21:26:19 GMT+0000 (Coordinated Universal Time)

@abdul_rehman #java

star

Sat Feb 24 2024 21:00:21 GMT+0000 (Coordinated Universal Time)

@abdul_rehman #java

star

Sat Feb 24 2024 20:28:43 GMT+0000 (Coordinated Universal Time)

@abdul_rehman #java

star

Sat Feb 24 2024 11:38:25 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/covariance-contravariance/variance-in-delegates

@ni3

star

Sat Feb 24 2024 11:13:59 GMT+0000 (Coordinated Universal Time)

@msaadshahid

star

Sat Feb 24 2024 11:08:27 GMT+0000 (Coordinated Universal Time)

@abdul_rehman #java

star

Sat Feb 24 2024 10:57:06 GMT+0000 (Coordinated Universal Time)

@abdul_rehman #java

star

Sat Feb 24 2024 10:51:56 GMT+0000 (Coordinated Universal Time)

@msaadshahid

star

Sat Feb 24 2024 10:46:28 GMT+0000 (Coordinated Universal Time)

@msaadshahid

star

Sat Feb 24 2024 10:36:19 GMT+0000 (Coordinated Universal Time)

@abdul_rehman #java

star

Sat Feb 24 2024 10:17:14 GMT+0000 (Coordinated Universal Time)

@msaadshahid

star

Sat Feb 24 2024 10:14:16 GMT+0000 (Coordinated Universal Time)

@msaadshahid

star

Sat Feb 24 2024 09:54:33 GMT+0000 (Coordinated Universal Time)

@abdul_rehman #java

star

Sat Feb 24 2024 09:50:22 GMT+0000 (Coordinated Universal Time)

@msaadshahid

star

Sat Feb 24 2024 09:43:31 GMT+0000 (Coordinated Universal Time)

@msaadshahid

star

Sat Feb 24 2024 09:36:22 GMT+0000 (Coordinated Universal Time)

@msaadshahid

star

Sat Feb 24 2024 08:53:44 GMT+0000 (Coordinated Universal Time)

@abdul_rehman #java

star

Sat Feb 24 2024 08:43:45 GMT+0000 (Coordinated Universal Time)

@msaadshahid

star

Sat Feb 24 2024 02:54:33 GMT+0000 (Coordinated Universal Time) https://www.google.com/search?q

@trixx

star

Sat Feb 24 2024 01:09:07 GMT+0000 (Coordinated Universal Time)

@vjg

star

Fri Feb 23 2024 21:36:55 GMT+0000 (Coordinated Universal Time)

@NoobAl

star

Fri Feb 23 2024 17:58:14 GMT+0000 (Coordinated Universal Time)

@NoobAl

star

Fri Feb 23 2024 17:48:53 GMT+0000 (Coordinated Universal Time)

@TranDucAnh

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension