






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







import java.io.*; class CaesarCipherProgram { public static void main(String args[])throws Exception { String pt,ct=""; int key=3; BufferedReader brk=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter Plain Text: "); pt=brk.readLine(); pt=pt.toLowerCase(); for(int i=0;i<pt.length();i++) { int acvalue=(int)pt.charAt(i); acvalue=acvalue+key; if(acvalue>122) { int diff=acvalue-122; acvalue=96+diff; } ct=ct+(char)acvalue; } System.out.print(ct); } }
Output-
import java.util.Scanner; public class MonoalphabeticCipher { public static char p[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; public static char ch[]={'Q','W','E','R','T','Y','U','I','O','P','A','S','D','F','G','H','J','K','L','Z','X','C','V','B','N','M'}; public static String doEncryption (String s) { char c[]=new char[(s.length())]; for (int i = 0;i<s.length();i++) { for (int j = 0;j<26;j++) { if(p[j] == s.charAt(i)) { c[i] = ch[j]; break; } } }
Output-
import java.io.*; class Railfence { public static void main(String args[])throws Exception { String pt,ct=""; BufferedReader brk=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter Plain Text: "); pt=brk.readLine(); pt=pt.toLowerCase(); for(int i=0; i<pt.length(); i++) { if(i%2==0) ct=ct+pt.charAt(i); } for(int i=0; i<pt.length(); i++) { if(i%2!=0) ct=ct+pt.charAt(i); } System.out.println("Cipher Text " +ct);
msg = 11 print(f'Original message:{msg}') C = pow(msg, e) C = math.fmod(C, n) print(f'Encrypted message: {C}') M = pow(C, d) M = math.fmod(M, n) print(f'Decrypted message: {M}') Output-
import hashlib result=hashlib.md5(b'Ismile') result1=hashlib.md5(b'Esmile') print("The byte equivalent of hash is: ",end="") print(result.digest()) print("The byte equivalent of hash is: ",end="") print(result1.digest())
import hashlib str = input("Enter the value to encode") result = hashlib.sha1(str.encode()) print("The hexadecimal equivalent of SHA1 is: ") print(result.hexdigest())
from random import randint if name == 'main': P = 23 G = 9 print('The Value of P is :%d'%(P)) print('The Value of G is :%d'%(G)) a = 4 print('Secret Number for Alice is :%d'%(a)) x = int(pow(G,a,P)) b = 6 print('Secret Number for Bob is :%d'%(b)) y = int(pow(G,b,P)) ka = int(pow(y,a,P)) kb = int(pow(x,b,P)) print('Secret key for the Alice is : %d'%(ka)) print('Secret Key for the Bob is : %d'%(kb))