• 10 Jan 2009 /  Programming

    Well there’s never really been a  great place on the web for me to find out how, and after a lot of searching and trial and error, I found a way that works. If you have the JDK correctly installed and working in the classpath, go to Start->Run->cmd and hit enter, or vista users Start->type in cmd in the searchbox->enter / click the only thing that shows up. Now type in “cd C:/path/to/your/directory” to get to the current directory of your jar file.

    keytool -genkey -alias YOURALIAS -keystore YOURSTORE 
    -keypass KEYPASS -dname "cn=YOUR NAME" -storepass STOREPASS
    jarsigner -keystore YOURSTORE -storepass STOREPASS -keypass KEYPASS 
    -signedjar SIGNEDJAR.jar ORIGJAR.jar YOURALIAS
    keytool -export -keystore YOURSTORE -storepass STOREPASS 
    -alias YOURALIAS -file YOURCERT.cer

    Just replace what’s in capitals for your own values, and it should work happily.

    ** NOTICE: Wordpress is one big failure at wordwrapping. I had to split each of these into two lines. The second line should still be on the first line in the command prompt, and there should be a space between “YOURSTORE -keypass” like that.

    Tags:

  • 24 Dec 2008 /  Programming

    So, a long time ago (probably 2 years), I created 2 functions using the GameMaker engine that did super simple XOR encryption. XOR encryption is often debatable as being true encryption or not; but I call it encryption anyway. It’s easy to crack and should NOT be used for sensitive data, there are stronger methods out there. Now, onto the simple and short source.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    
    public String xorEnc(int encKey, String toEnc) {
            /*
                Usage: str = xorEnc(integer_key,string_to_encrypt);
                Created by Matthew Shaffer (matt-shaffer.com)
            */
            int t=0;
            String s1="";
            String tog="";
            if(encKey>0) {
                while(t < toEnc.length()) {
                    int a=toEnc.charAt(t);
                    int c=a ^ encKey;
                    char d=(char)c;
                    tog=tog+d;
                    t++;
                }
     
            }
            return tog;
        }
        public String xorEncStr(String encKey, String toEnc) {
            /*
                Usage: str = xorEnc(string_key,string_to_encrypt);
                Created by Matthew Shaffer (matt-shaffer.com)
            */
            int t=0;
            int encKeyI=0;
     
            while(t < encKey.length()) {
                encKeyI+=encKey.charAt(t);
                t+=1;
            }
            return xorEnc(encKeyI,toEnc);
        }

    I’m not going to bother explaing much how these two functions work. Using them is simple and you should read the comments in the functions, and I’m pretty sure all you want to do is rip them anyway. xorEncStr basically converts the string key you provide it into an integer and passes it to xorEnc. Both of the above functions have been tested to work!

    Tags: , , ,

  • 21 Dec 2008 /  Programming

    There are just some things that google can never tell you, and no matter how hard you try to search for it you may never find what you are looking for. That happened to me when I tried to find out how to convert a String to an Integer array in Java. So, here’s the simple function that will do this:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    public static int[] strToInt (String inp) {
       int[] toRet = new int[inp.length()];
       int i = 0;
       while(i < inp.length()) {
          toRet[i]=(int)inp.charAt(i);
          i++;
       }
       return toRet;
    }

    This function goes through every character of the string and gets the integer value of the character and adds it to the integer array. When it’s done adding everything, it returns the integer array with the same length as the string.

    (PS: Sorry for unindented code; I’ll have to find a better code plugin..)

    Tags: ,