Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypt done #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 76 additions & 13 deletions Crypto/src/ROT13.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,95 @@

import static java.lang.Character.isLowerCase;
import static java.lang.Character.isUpperCase;
import static java.lang.Character.toLowerCase;

public class ROT13 {
import java.io.*;



public class ROT13 {

private int shift;

ROT13(Character cs, Character cf) {

ROT13(Character cs, Character cf) {

shift=cf-cs;
}

ROT13() {
shift=0;
}
//lets read a file ,encode it and write in



public String crypt(String text) throws UnsupportedOperationException {

return "";




public String crypt(String text) throws UnsupportedOperationException {
return decrypt(encrypt(text));
}

public String encrypt(String text) {
return text;
}
return shiftString(text, (char) (97 + shift));



}

public String decrypt (String text){
return shiftString(text, (char) (97 + 26 - shift));

}
public String shiftString(String text,Character c) {
int shift;
if (c >= 97 && c <= 122) {
shift = c - 97;
} else {
shift = c - 65;
}

StringBuffer result = new StringBuffer();
char[] charArr = text.toCharArray();
for (int i = 0; i < charArr.length; i++) {
if (charArr[i] <= 90 && charArr[i] >= 65) {
charArr[i] = (char) ((charArr[i] + shift - 65) % 26 + 65);


}
if (charArr[i] <= 122 && charArr[i] >= 97) {
charArr[i] = (char) ((charArr[i] + shift - 97) % 26 + 97);


}

}

return String.valueOf(charArr);
}

public static String rotate (String s, Character c){
String str="";
int l=s.indexOf(c);
for(int i=l; i<s.length();i++){
str=str+s.charAt(i);
}
for(int i=0;i<l;i++){
str=str+s.charAt(i);
}


return str;


}



public String decrypt(String text) {
return text;
}

public static String rotate(String s, Character c) {

return "";
}

}
}
3 changes: 3 additions & 0 deletions Crypto/src/ROT13Test.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


import org.junit.Test;

import static org.junit.Assert.*;
Expand Down Expand Up @@ -88,4 +90,5 @@ public void cryptTest2() {
assertTrue(actual.equals(Q1));
}


}
15 changes: 15 additions & 0 deletions SimpleCrypt.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/Crypto/src" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>
20 changes: 20 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@
<groupId>com.zipcodewilmington</groupId>
<artifactId>SimpleCrypt</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>


</project>
Empty file added target/sonnet18.enc
Empty file.
Binary file not shown.