| | |
Encryption -- Custom algorithm
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
I'm trying to write this method that takes some parameters from my text editor, and encrypt the text. I got part of it written, but I'm stuck on the next bit.
I got the part where you convert the "key", but I just can't figure out what to do next.
I got the part where you convert the "key", but I just can't figure out what to do next.
Java Syntax (Toggle Plain Text)
import java.util.*; public class Encryptor { public String encryptText(String key, String text) { String finalResult = ""; for (int i=0; i<key.length(); i++) { long convert = (long)key.charAt(i); convert *= 128; finalResult += convert; } Random randomNumGenerator = new Random(keyResult); String returnString = ""; return returnString; } }
•
•
Join Date: Mar 2005
Posts: 53
Reputation:
Solved Threads: 1
•
•
•
•
Originally Posted by server_crash
I'm trying to write this method that takes some parameters from my text editor, and encrypt the text. I got part of it written, but I'm stuck on the next bit.
I got the part where you convert the "key", but I just can't figure out what to do next.
Java Syntax (Toggle Plain Text)
import java.util.*; public class Encryptor { public String encryptText(String key, String text) { String finalResult = ""; for (int i=0; i<key.length(); i++) { long convert = (long)key.charAt(i); convert *= 128; finalResult += convert; } Random randomNumGenerator = new Random(keyResult); String returnString = ""; return returnString; } }
Your post is not clear. What exactly are you trying to do. You want to encrypt text and for that you have a key, right. You can use XOR alogo to encrypt your text. If you are following a specific algorithm let me know. I am not able to understand where exactly you are stuck up ?
cheers,
aj.wh.ca
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
Here's a short example of how to shift the text one letter over. I'm trying to do something similar to this, except using a key(the seed), and using random values.
Java Syntax (Toggle Plain Text)
public class CeaserCypher { public String shiftOne(String text) { long convert = 0; String finalResult = ""; for (int i=0; i<text.length(); i++) { convert = (long)text.charAt(i) +1; finalResult += (char)convert; } return finalResult; } }
![]() |
Similar Threads
- base64 encryption (PHP)
- Password encrypt/decrypt (Java)
- How to encryption/decryption algorithm for mdb table? (Visual Basic 4 / 5 / 6)
- Peer To Peer File Sharing Program (Computer Science)
Other Threads in the Java Forum
- Previous Thread: Calling Object Methods within a LinkedList
- Next Thread: Help...How do i use the Tokenizer?
| Thread Tools | Search this Thread |
Tag cloud for Java
@param add android api apple applet application arguments array arrays automation bank binary binarytree bluetooth bold chat chatprogramusingobjects class classes client code compare component coordinates database digit draw eclipse editor error event exception fractal game givemetehcodez graphics gui guidancer health html ide image input int integer integration j2me jarfile java javac javame javaprojects jmf jni jpanel julia keytool learningresources linux list loop map method methods mobile netbeans newbie nonstatic number oracle pattern print problem program programming project projectideas recursion scanner screen server set sharepoint size sms socket sort sorting sql sqlserver string swing test text-file threads time tree web windows






