Posts

MD5 in java

import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class MD5 { public static String getMD5(String input) { try { MessageDigest   md=MessageDigest.getInstance("MD5"); byte[] messageDigest = md.digest(input.getBytes()); BigInteger number = new BigInteger(1, messageDigest); String hashtext = number.toString(16); // Now we need to zero pad it if you actually want the full 32 chars. while (hashtext.length() < 32) { hashtext = "0" + hashtext; } return hashtext; } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } } public static void main(String[] args) throws NoSuchAlgorithmException { String s="hello world"; System.out.println("your hashcode generated by MD5 is:"+getMD5(s)); } }

DES,Blowfish,AES(rijndael),RC4

import javax.crypto.*; import java.util.*; public class Blowfish { public static void main(String[] args)throws Exception { SecretKey key=KeyGenerator.getInstance("BlowFish").generateKey(); Cipher cip=Cipher.getInstance("BlowFish"); cip.init(Cipher.ENCRYPT_MODE,key); Scanner s=new Scanner(System.in); String pt=s.next(); byte[] encrypted=cip.doFinal(pt.getBytes()); cip.init(Cipher.DECRYPT_MODE,key); byte[] ct=cip.doFinal(encrypted); System.out.println("the new encrypted string is"+new String(encrypted)+"old string is"+new String(ct)); } }

Diffie Hellman java code

import java.util.*;   class Diffie_Hellman { public static void main( String args[]) { Scanner sc= new Scanner(System. in ); System.out.println( "Enter modulo(p)" ); int p=sc.nextInt(); System.out.println( "Enter primitive root of " +p); int g=sc.nextInt(); System.out.println( "Choose 1st secret no(Alice)" ); int a=sc.nextInt(); System.out.println( "Choose 2nd secret no(BOB)" ); int b=sc.nextInt(); int A = ( int )Math.pow(g,a)%p; int B = ( int )Math.pow(g,b)%p; int S_A = ( int )Math.pow(B,a)%p; int S_B =( int )Math.pow(A,b)%p; if (S_A==S_B) { System.out.println( "ALice and Bob can communicate with each other!!!" ); System.out.println( "They share a secret no = " +S_A); } else { System.out.println( "ALice and Bob cannot communicate with each other!!!" ); } } }

PROGRAM TO IMPLEMENT FIFO DISK SCHEDULING ALGORITHM IN C

Image
/*     FCFS Disk Scheduling Algorithm    Created by: shobabu */ #include<stdio.h> #include<conio.h> void main() { int queue[100],n,head,i,j,k,seek=0,diff; float avg; // clrscr();   printf("*** FCFS Disk Scheduling Algorithm ***\n"); printf("Enter the size of Queue\t"); scanf("%d",&n); printf("Enter the Queue\t"); for(i=1;i<=n;i++)   {     scanf("%d",&queue[i]);   }   printf("Enter the initial head position\t"); scanf("%d",&head); queue[0]=head; printf("\n"); for(j=0;j<=n-1;j++) {     diff=abs(queue[j+1]-queue[j]);     seek+=diff;     printf("Move from %d to %d with Seek %d\n",queue[j],queue[j+1],diff);   } printf("\nTotal Seek Time is %d\t",seek);   avg=seek/(float)n; printf("\nAverage Seek Time is %f\t",avg);   getch(); }

PROGRAM TO IMPLEMENT SSTF DISK SCHEDULING ALGORITHM IN C

Image
/*    SSTF Disk Scheduling Algorithm    Created By: shobabu */ #include<stdio.h> #include<conio.h> #include<math.h> void main() { int queue[100],t[100],head,seek=0,n,i,j,temp; float avg; // clrscr(); printf("*** SSTF Disk Scheduling Algorithm ***\n"); printf("Enter the size of Queue\t"); scanf("%d",&n); printf("Enter the Queue\t"); for(i=0;i<n;i++) {     scanf("%d",&queue[i]); } printf("Enter the initial head position\t"); scanf("%d",&head);   for(i=1;i<n;i++)   t[i]=abs(head-queue[i]); for(i=0;i<n;i++)   {     for(j=i+1;j<n;j++)     {       if(t[i]>t[j])       {         temp=t[i];         t[i]=t[j];         t[j]=temp;         temp=queue[i];         queue[i]=queue[j];         queue[j]=tem...

get the new moto g5s plus

Image
get the new moto g5s plus by clicking the below link http://amzn.to/2wUSzmD

moto g5s plus

Image
Best phone with all advanced features best dual camera  metal body Full specifications operating system Android™ 7.1, Nougat system architecture/processor Qualcomm ®  Snapdragon™ 625 processor with 2.0 GHz octa-core CPU and 650 MHz Adreno 506 GPU memory (RAM) 4 GB storage (ROM) 64 GB internal, up to 128 GB microSD Card support dimensions Height: 153.5 mm Width: 76.2 mm Depth: 8.0mm to 9.5 mm weight 168 g display 13.97cm (5.5”) Full HD 1080p (1920×1080) 401 ppi Corning™ Gorilla™ Glass 3 battery All-day battery (3000 mAh) TurboPower™ for up to 6 hours of power in 15 minutes of charging * water protection Water repellent nano-coating § network 4G LTE (Cat 7) UMTS/HSPA+ GSM/EDGE bands (by model) Moto G 5 S  Plus – XT1804 GSM/GPRS/EDGE (850, 900, 1800, 1900 MHz) UMTS/HSPA+ (850, 900, 1900, 2100 MHz) 4G LTE (B1, 3, 5, 8, 28, 40)† SIM Card ...