SECURITY / CATATAN</>↗Security04 Agt 2008
package org.kodejava.security; import java.security.Provider; import java.security.Security; import java.util.Set; import java.util.HashSet; public class SecurityProvider { public static void main(String[] args) { // Create a set so that we can have a unique results. Set<String> results = new HashSet<>(); // Returns an array containing all the installed providers. Provider[] providers = Security.getProviders(); for (Provider provider : providers) […]
CORE API / CATATAN</>↗Core API03 Agt 2008
On the previous example How do I encrypt an object with DES? we encrypt an object. In this example we will decrypt the stored object. package org.kodejava.crypto; import java.io.*; import javax.crypto.SecretKey; import javax.crypto.Cipher; import javax.crypto.SealedObject; public class ObjectDecrypt { public static void main(String[] args) throws Exception { // Read the previously stored SecretKey. SecretKey key […]
CORE API / CATATAN</>↗Core API02 Agt 2008
This example demonstrate encrypting an object using DES algorithm. After the object was encrypted we store it in a file which will be decrypted in the next example here How do I decrypt an object with DES. package org.kodejava.crypto; import java.io.*; import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.SealedObject; import javax.crypto.SecretKey; public class ObjectEncrypt { public static […]
CORE API / CATATAN</>↗Core API01 Agt 2008
This code checks a string to determine if it is a palindrome or not. A palindrome is a word, phrase, or sequence that reads the same backward as forward. package org.kodejava.lang; public class PalindromeChecker { public static void main(String[] args) { String text = "Sator Arepo Tenet Opera Rotas"; PalindromeChecker checker = new PalindromeChecker(); System.out.println("Is […]
CORE API / CATATAN</>↗Core API29 Jul 2008
Here is the second way for creating a thread. We create an object that implements the java.lang.Runnable interface. For another example see How do I create a thread by extending Thread class?. package org.kodejava.lang; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; public class TimeThread implements Runnable { private final DateFormat df = new SimpleDateFormat("hh:mm:ss"); // The […]
CORE API / CATATAN</>↗Core API28 Jul 2008
There are two ways that we can use tho create a thread. First is by extending the java.lang.Thread class and the second way is by creating a class that implements the java.lang.Runnable interface. See How do I create a thread by implementing Runnable interface? In this example we’ll extend the Thread class. To run a […]