Simple encryption method
Hey i am trying to create a simple encryption. This is my function.
public static String Crypt(String sData)
byte[] bytes = sData.getBytes();
for(int i=0; i<bytes.length; i++)
bytes[i] ^= 477;
return (new String(bytes));
Unfortunately the String that is returned has a lot of "???????" in it. I have also tried char arrays but to no effect. I want to be able to send the data using a socket therefore i need it in a char array or string. Can anyone help please?
>
return (new String(bytes));
Unfortunately the String that is returned has a lot of
"???????" in it. I have also tried char arrays but to
no effect. I want to be able to send the data using a
socket therefore i need it in a char array or string.1) Not all byte and byte combinations produce a valid String object so one cannot use 'new String(bytes)' with the certainty of being able to reverse the operation and get back the original bytes. i.e.
new String(some bytes).getBytes() usually does not return 'some bytes'.
2) You don't need to have a char array or string to send bytes down a Socket. Just send down the encrypted bytes.
3) I hope you are not considering this encryption method for an industrial strength application!
Similar Messages
-
Simple encryption... need help...
hello friends,
this may be a simple problem, but, as i m new plz forgive me...
i have to accept three command line agrumetns like...
name ---> string
age ---> integer
date ---> string
now, i want to encrypt these data in a two different text files with two different encryption methods...
and later i need to decrypt the data from both the textfiles...
can anyone help me how can i achieve this task ???
Thanks,
Rohanhi arshad,
thanks for the guidence...
i just needed the proper direction... not the code...
Thanks again...
i went through some books and tried a sample code from a book...
here is the code...
package des;
import java.io.*;
import java.security.*;
import javax.crypto.*;
import sun.misc.*;
* @author Rohan.Nakar
public class SecretWriting
public static void main(String[] args) throws Exception
//checking argumetns
if(args.length < 2)
System.out.println("Usage: SecureWriting -e | -d plainText");
return;
//get or create key
Key key;
try
ObjectInputStream in = new ObjectInputStream( new FileInputStream("SecretKey.ser"));
key = (Key)in.readObject();
in.close();
catch (FileNotFoundException fnfe)
KeyGenerator generator = KeyGenerator.getInstance("DES");
generator.init(new SecureRandom());
key = generator.generateKey();
ObjectOutputStream out = new ObjectOutputStream( new FileOutputStream("SecretKey.ser"));
out.writeObject(key);
out.close();
//get a cipher object
Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
//Encrypt or decrypt the input string
if (args[0].indexOf("e") != -1)
cipher.init(Cipher.ENCRYPT_MODE, key);
String amalgam = args[1];
for(int i = 2; i < args.length; i++)
amalgam += " " + args;
byte[] stringBytes = amalgam.getBytes("UTF8");
byte[] raw = cipher.doFinal(stringBytes);
BASE64Encoder encoder = new BASE64Encoder();
String base64 = encoder.encode(raw);
System.out.println(base64);
else if (args[0].indexOf("d") != -1)
cipher.init(Cipher.DECRYPT_MODE, key);
BASE64Decoder decoder = new BASE64Decoder();
byte[] raw = decoder.decodeBuffer(args[1]);
byte[] stringBytes = cipher.doFinal(raw);
String result = new String(stringBytes, "UTF8");
System.out.println(result);
this is giving me an exception...
java.security.NoSuchAlgorithmException: Algorithm DES not available
at javax.crypto.SunJCE_b.a(DashoA6275)
at javax.crypto.KeyGenerator.getInstance(DashoA6275)
at des.SecretWriting.main(SecretWriting.java:40)
Exception in thread "main"
any help...
Thanks in advance... -
Search Encrypt Methods Of Spatial Data !!!
Hi:
Hello,Everybody!
I trying to search encrypt methods of spatial data(vector data),whether some also made a study of this aspect ,Can anyone guide to me ?
Li in ChinaYes have read it that's why my query looks a lot like that sample...
Turns out the objects are transferring but that the Oracle provider for OLE DB
converts the VARBINARY(MAX) from SQL Server to LONG and given this has
a length limit some of the spatial records are being truncated...
Anybody know if a different provider would work or of a way of overridding the
mapping to LONG with a different and longer Oracle datatype? -
Hi there,
Where can i find a very simple encryption algorithm to allow me to encrypt basic strings?
It should be simple enough so i can make a version for Java and Cobol.
Thanks for any help.I guess you can implement any encryption algorithm with either language. XOR should suffice... just not ROT13, it'll be a pain with EBCDIC. XOR each byte with some byte you randomly picked.
-
Which encryption method is the best way to secure the data tranfer
Hi ,
I want to configure the Encryption between two cisco Wan routers(3845 & 3825).
We use 50MB leased line connection and transfer the data. I also configured the QOS to limit the data transfer rate to 20MB on the same pipe and it's working fine.We also use the same pipe for trading purpose too. That's why I limit 20MB for data(copy) transfer between two hosts.
Which encryption method should I use to secure the data transfer?
Plese kinldy advise .
Thanks,Disclaimer
The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.
Liability Disclaimer
In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.
Posting
I would recommend AES256.
I would also recommend a VTI tunnel vs. GRE/IPSec. However, both, depending on your IOS, should support AES256.
Encryption will demand more from your routers. I think the 3845 should be able to support 20 Mbps encrypted, not as sure about the 3825. (BTW, if you have 50 Mbps LL, why are you limited transfer rate to 20 Mbps?)
Also BTW, there's much involved in setting up encrypted tunnels for optimal performance. Also see: http://www.cisco.com/c/en/us/support/docs/ip/generic-routing-encapsulation-gre/25885-pmtud-ipfrag.html -
Phase 1 Encryption Method in Config File
OK... I see the statement for the declaration of Encryption for Phase 2. It is clear in the Crypto Map section. Where in the config file is the Phase 1 encryption method defined for a given IPSec Tunnel?
ThanxHi,
From the ASA CLI you should be able to see all the phase 1 policies configured on the ASA with the command "show run crypto". They are at the very end.
Each of the policies have a priority number in which order they are checked when a VPN connection is being formed.
To my understanding none of them are locked to a certain VPN connection on your ASA. They are gone through with the other VPN device/client in the Phase1 negotiations until they find a policy match that both devices have.
In my 8.4(3) ASA I for example have the policies like this
crypto ikev1 policy 30
authentication pre-share
encryption aes-256
hash sha
group 2
lifetime 86400
crypto ikev1 policy 60
authentication pre-share
encryption aes-192
hash sha
group 2
lifetime 86400
For the older software the format might be different.
Like
"crypto isakmp policy 10"
- Jouni -
Hi All,
This is my first post to ms exchange forum am getting Log onto incoming mail server (POP3): Your server does not support the connection encryption type you have specified. Try changing the encryption method. Contact your mail server administrator
or Internet service provider (ISP) for additional assistance. in my outlook clients, till last Sunday (12.04.15) my exchange was well & good, Monday morning suddenly the problem started like none of our outlook pop3 clients are able to communicate
with exchange (rest IMAP, SMTP & Exchange accounts are working fine). i have tried with all port no but no luck. please help me to get raid of this one.
Exchange 2013 CU6 with server 2012 Std 64Bit
Thanks,
MuraliDear All,
I have found the solution for above problem, the problem has occur due to PopProxy inactivity
please find relevant exchange management shell commends below.
1. Get-ServerComponentstate -Identity <yourmailserver.com>
Server Component State
yourmailserver.com ServerWideOffline Active
yourmailserver.com HubTransport Active
yourmailserver.com FrontendTransport Active
yourmailserver.com Monitoring Active
yourmailserver.com RecoveryActionsEnabled Active
yourmailserver.com AutoDiscoverProxy Active
yourmailserver.com ActiveSyncProxy Active
yourmailserver.com EcpProxy Active
yourmailserver.com EwsProxy Active
yourmailserver.com ImapProxy Active
yourmailserver.com OabProxy Active
yourmailserver.com OwaProxy Active
yourmailserver.com PopProxy Inactive
yourmailserver.com PushNotificationsProxy Active
yourmailserver.com RpsProxy Active
yourmailserver.com RwsProxy Active
yourmailserver.com RpcProxy Active
yourmailserver.com UMCallRouter Active
yourmailserver.com XropProxy Active
yourmailserver.com HttpProxyAvailabilityGroup Active
yourmailserver.com ForwardSyncDaemon Active
yourmailserver.com ProvisioningRps Active
yourmailserver.com MapiProxy Active
yourmailserver.com EdgeTransport Active
yourmailserver.com HighAvailability Active
yourmailserver.com SharedCache Active
2. Set-ServerComponentState -Identity <yourmailserver.com> -Component PopProxy -Requester HealthAPI
-State Active
3. Get-ServerComponentstate -Identity <yourmailserver.com>
Server Component State
yourmailserver.com ServerWideOffline Active
yourmailserver.com HubTransport Active
yourmailserver.com FrontendTransport Active
yourmailserver.com Monitoring Active
yourmailserver.com RecoveryActionsEnabled Active
yourmailserver.com AutoDiscoverProxy Active
yourmailserver.com ActiveSyncProxy Active
yourmailserver.com EcpProxy Active
yourmailserver.com EwsProxy Active
yourmailserver.com ImapProxy Active
yourmailserver.com OabProxy Active
yourmailserver.com OwaProxy Active
yourmailserver.com PopProxy Active
yourmailserver.com PushNotificationsProxy Active
yourmailserver.com RpsProxy Active
yourmailserver.com RwsProxy Active
yourmailserver.com RpcProxy Active
yourmailserver.com UMCallRouter Active
yourmailserver.com XropProxy Active
yourmailserver.com HttpProxyAvailabilityGroup Active
yourmailserver.com ForwardSyncDaemon Active
yourmailserver.com ProvisioningRps Active
yourmailserver.com MapiProxy Active
yourmailserver.com EdgeTransport Active
yourmailserver.com HighAvailability Active
yourmailserver.com SharedCache Activ
Replace yourmailserver.com with your server host name.
Thanks -
what is your best encryption method..
please give me a link or an example please..w32sysfie wrote:
what is your best encryption method..
I suppose you'e moved on to bigger and better duke-whoring, but I just want to point out that this is a meaningless question. There's no single measure of goodness for encryption. If you want "best", you'll have to define your criteria.
Hardest to break?
Easiest to implement?
Fastest to execute?
Best supported in standard libraries on various platforms?
Most likely it's not a single one of those, but there are weights on all of them. Only you know your requirements, and without more information, there's no way anybody can tell you what's "best" for your needs. -
What is the encryption method for the user's password?
hi all,
who knows what is the encryption method for the user's password?
the password is 803004, and i get the encrypted string "D7EDED84BC624A917F5B462A4DCA05CDCE256EEEEEDC97D59A57930E06CF9781E022CC8E430FF04E"
thanks,
danThere is no default password for a guest user unless you've created one:
(screenshot from the System Pref Guest User Pane) -
The network does not support the requested encryption method
Prior to last night, I had connected to several wireless networks without issue, so I know my computer can do it. The issue started after I reinstalled the operating system. I connected to my friends wireless network last night with no problems, using the password. My system was having other unrelated problems so I decided to reinstall the operating system since the computer had just had a new hard drive put in anyway. Then when I tried to get online after everything was up and running, I couldn't.
Wireless networks show up fine, but when I go to log in, enter the password and hit connect, after a second I get the error message : "The network "name" does not support the requested encryption method". I've scoured the help topics, searched high and low, and tried everything. Please help
Message was edited by: Eden51086After you reinstalled the OS, you may need to download install any Airport Updates as well.
-
Whats the encryption method & cipher strength that I should choose?
Whats the encryption method & cipher strength that I should choose if I deploy the mbam to both Windows 7 and Windows 8 computers?
JasonWell, the answer is- it depends.
What is the objective of your encryption? with 128 AES; the bits used to encrypt data is lesser than that of 256 AES so you are more secure with 256 AES than if you have selected 128 AES; the flip side is this- since data encryption and decryption
is done on the fly when the machine is booted up; performance penalty- how minuscule it is will be more in the drives that are encrypted with 256 AES.
Mayank Sharma Support Engineer at Microsoft working in Enterprise Platform Support. -
Simple Encryption and Simple Question
Anyway, I hope it is simple!
This is from an example in my text book, I have coded it up and it works great. I think I understand everything except for the subtraction of 'A' in the encryptMessage method. Any ideas? I thought it may be subtracting the ASCII value of 'A', but isn't that just 1?
Any help is appreciated.
public class CeasarCryptography
public static final int ALPHASIZE = 26; //Standard English alphabet size, ALL uppercase
public static char[] alpha = {'A','C','B','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
protected char[] encryptionKey = new char[ALPHASIZE];
protected char[] decryptionKey = new char[ALPHASIZE];
public CeasarCryptography()
//Initializes encryptionArray
for (int x = 0; x < encryptionKey.length; x++)
encryptionKey[x] = alpha[ (x + 3) % ALPHASIZE ]; //Rotate alphabet by three places
//Initializes encryptionArray and decryptionArray
for (int x = 0; x < decryptionKey.length; x++)
decryptionKey[encryptionKey[x] - 'A'] = alpha[x]; //Decypt is revers of encrypt
public String encryptMessage(String secret)
char[] mess = secret.toCharArray(); //First, place the string in an array
for (int x = 0; x < mess.length; x++)
if (Character.isUpperCase(mess[x]))
mess[x] = encryptionKey[mess[x] - 'A'];
return new String(mess);
public String decryptMessage(String secret)
char[] mess = secret.toCharArray();
for (int x = 0; x < mess.length; x++)
if (Character.isUpperCase(mess[x]))
mess[x] = decryptionKey[mess[x] - 'A'];
return new String(mess);
public static void main(String[] args)
CeasarCryptography cipherObject = new CeasarCryptography();
System.out.println("Welcome to the oldest known enryption program.");
System.out.println("\tEncryption Key: " + new String(cipherObject.encryptionKey));
System.out.println("\tDecryption Key: " + new String(cipherObject.decryptionKey));
String testString = "JAVA IS NOT EASY";
System.out.println("\nEncrypt the following: " + testString);
System.out.println("\tOnce encrypted: " + cipherObject.decryptMessage(testString));
}If the value of 'A' is not important, how is 'D' -
'A' 3? Because D is 3 later than A. So whether 'A' is -123 or 0 or 1 or 65, 'A' + 3 is always 'D'.
Or is this D (which is the 4th letter) minus A
(which is the 1st letter) for 4-1 = 3. Right. It's just that in ASCII, 'A' is 65, instead of 1 or 0 that we usually think of it. The whole minus 'A' part is just to say "how far away from A are we, and therfore how much are we shifting?"
And 3 is the
element in the Array that D is in?I was winging it here but that's what it comes down to. Whether it's an index into an array where 'A' is in 0, 'B' is in '1', etc., or just an on-the-fly shifting, either way, "minus 'A'" ultimately means "How far away from A is this letter?" -
Hi All, I want to encrypt a simple text as given in the example below BUT I am getting 'java.lang.NoSuchMethodError' Exception at the Cipher.getInstance("DES") method.
Please help me or give me some references.
Write me at [email protected]
This is the test code -
Cipher desCipher;
byte[] desKeyData = { (byte)0x01, (byte)0x02, (byte)0x03,..};
SecretKeySpec desKey = new SecretKeySpec(desKeyData, "DES");
// Getting Exception at this point
desCipher = Cipher.getInstance("DES");
desCipher.init(Cipher.ENCRYPT_MODE, desKey);
// Our cleartext
byte[] cleartext = "This is just an example".getBytes();
// Encrypt the cleartext
byte[] ciphertext = desCipher.doFinal(cleartext);
// Initialize the same cipher for decryption
desCipher.init(Cipher.DECRYPT_MODE, desKey);
// Decrypt the ciphertext
byte[] cleartext1 = desCipher.doFinal(ciphertext);try this:
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.CipherOutputStream;
import javax.crypto.SealedObject;
import java.security.*;
import java.io.*;
import javax.crypto.*;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.KeyAgreement;
import javax.swing.*;
public class encryptTest
public static void main(String args[])
String password = JOptionPane.showInputDialog(null,"Plz Enter Any word to Encrypt");
Security.addProvider(new com.sun.crypto.provider.SunJCE());
try
KeyGenerator kg = KeyGenerator.getInstance("DES");
Key key = kg.generateKey();
Cipher cipher = Cipher.getInstance("DES");
cipher.init(Cipher.ENCRYPT_MODE,key);
byte[] encrypted_password = cipher.doFinal(password.getBytes());
JOptionPane.showMessageDialog(null,"Encrypted Password "+ new String(encrypted_password));
cipher.init(Cipher.DECRYPT_MODE,key);
byte[] decrypted_password = cipher.doFinal(encrypted_password);
JOptionPane.showMessageDialog(null,"Decrypted Password "+new String(decrypted_password));
catch(NoSuchAlgorithmException nsae)
System.out.println("No Such Algorithm Exception " + nsae.getMessage());
catch(NoSuchPaddingException nspe)
System.out.println("No Such Padding Exception " + nspe.getMessage());
catch(InvalidKeyException ike)
System.out.println("Invalid Key Exception " + ike.getMessage());
catch(IllegalStateException ise)
System.out.println("Illegal State Exception " + ise.getMessage());
catch(IllegalBlockSizeException ibse)
System.out.println("Illegal Block Size Exception " + ibse.getMessage());
catch(BadPaddingException bpe)
System.out.println("Bad Padding Exception " + bpe.getMessage()); -
Simple repaint() method doubt
Hi Friends,
I have a simple program in which I need to print 2 strings at the same time.So,I pass the string and the location to the paint method,but the second repaint() method erases the first
string and only the second string is displayed.So,how can i make both the strings display at the same time.Here's a part of my code.
doPaint("String one",200,200);
validate();
doPaint("String two",200,250);
validate();
public void doPaint(String str,width x,height y){
this.x = x;
this.y = y;
this.str=str;
repaint();
public void paint(Graphics g){
super.paint(g);
g.setColor(Color.BLUE);
g.drawString(str,x,y);
}Thanksrepaint()clears the component and fills it from the scratch, so when you call your function for the second time it clears first string and draws only the second.
I advise to use two variables if you want them painted together.
And override paintComponent() not paint() -
Hi All ,
I am using the SAP R/3 4.7 Version. I need to encrypt password using standard algorithms .
I have tried function modiule FIEB_PASSWORD_ENCRYPT , VRM_COMPUTE_MD5 , MD5_CALCULATE_HASH_FOR_CHAR but that doesn't meet my requirement .
Would like to know if there is any function module or method that uses the standard encryption algorithm like 3DES , BlowFish , TwoFish , DES, MD5 , RC2 , Rijndael or SHA.
Regards ,
BinojHi Nair,
Actually I really would like to know how you resolved it, since I am using same SAP version and the FM´s do not work. Actually there is an abap error inside FM : FIEB_PASSWORD_ENCRYPT, in perform encrypt_password, in FORM character_search . If you correct this by adding the following line :
describe field im_string length l_length.
L_LENGTH = STRLEN( IM_STRING ).
Then FM FIEB_PASSWORD_ENCRYPT starts encripting without errors but FM FIEB_PASSWORD_DECRYPT does not completely works as expected, since some letters are not decrypted right.
So, it is a standard abap error and yet I did not sent a note so SAP asking for them to resolve this (I did not found any SAP Note in OSS System either).
Any light on this?, please !
Regards,
Maybe you are looking for
-
I had Photoshop CC, Dreamweaver CC, and Illustrator CC installed as a trial. The trial has now run out and I purchased an account for a full subscription to all adobe software, but in the creative cloud app it keeps prompting me as "your trial has ex
-
Software updates taking a very lonf time to download
I am deploying patch Tuesday software updates and I am seeing the download of updates to the clients taking a very long time (7 hours to download 11 updates). I have set BITS throttling to 100 Kbps in my Default Client Settings policy but I didn't th
-
Hello Sapians, The T-codes FAGLB03 and FS10N gives the Balances of any GL account and also Cumulative Balances. The Balances are divided in to Credits and Debits Columns. 1. So for a period, can Credit column carry positive balance (for example 1000
-
Is Windows 2003 Server supported as a server that MA can migrate?
Will Migration Accelerator support Windows Server 2003 as a source server that it can migrate to Azure? Tom Hickling
-
How do I bypass my passcode?
I can't believe I did this, but for reasons too embarrassing to explain, I've given my iPhone a passcode which I can't remember. What can I do to get rid of it and restore my access to my phone?