Created
July 6, 2018 18:51
-
-
Save eutkin/a98875160600ff52ddb629e64cd38005 to your computer and use it in GitHub Desktop.
public class Encryption { public String DEScrypt(String text, String key) { String cryptedString = null; // тело алгоритма return cryptedString; } public String RSAcrypt(String text, String key) { String cryptedString = null; // тело алгоритма return cryptedString; } public String GOSTcrypt(String text, String key) { String cryptedString = null;…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
/** | |
* @author eutkin | |
*/ | |
public enum CryptoAlgorithm implements Encryptor { | |
DES(new DESEncryptor()), GOST(new GOSTEncryptor()), RSA(new RSAEncryptor()); | |
private final Encryptor delegate; | |
CryptoAlgorithm(Encryptor delegate) { | |
this.delegate = delegate; | |
} | |
@Override | |
public String crypt(String text, String key) { | |
return delegate.crypt(text, key); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
public class DESEncryptor implements Encryptor { | |
@Override | |
public String crypt(String text, String key) { | |
String cryptedString = null; | |
// тело алгоритма | |
return cryptedString; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
import static com.company.CryptoAlgorithm.DES; | |
public class Encryption { | |
public static void main(String[] args) { | |
String key = "key"; | |
String text = "text"; | |
String cryptedText = DES.crypt(text, key); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
public interface Encryptor { | |
String crypt(String text, String key); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
public class GOSTEncryptor implements Encryptor { | |
@Override | |
public String crypt(String text, String key) { | |
String cryptedString = null; | |
// тело алгоритма | |
return cryptedString; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
public class RSAEncryptor implements Encryptor { | |
@Override | |
public String crypt(String text, String key) { | |
String cryptedString = null; | |
// тело алгоритма | |
return cryptedString; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment