What's new

Closed Ciphers & codes list ascii type: substitution

Status
Not open for further replies.
Example of Caesar Cipher (Java)

public static String encrypt(String pass){
StringBuilder encrypt = new StringBuilder();
int num0_3 = 50;
int upperA_C = 67;
int lowerA_C = 99;
int place = 3;
for (char c : pass.toCharArray()) {
int ascii = (int) c;
if(ascii <= num0_3){
ascii = 57 - (num0_3 - ascii);
encrypt.append((char) ascii);
}
else if(ascii <= upperA_C){
ascii = 90 - (upperA_C - ascii);
encrypt.append((char) ascii);
}
else if(ascii <= lowerA_C){
ascii = 122 - (lowerA_C - ascii);
encrypt.append((char) ascii);
}
else{
ascii -= place;
encrypt.append((char) ascii);
}
}
return encrypt.toString();
}
 
Last edited:
Status
Not open for further replies.
Back
Top