Home » Archives for Ilias Tsagklis » Page 29

Author Archives: Ilias Tsagklis

Avatar photo
Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.

DES with CBC using a nonce IV

Bipartite Graph

This is an example of how to make a DES example in CBC mode using a nonce Iv. Encrypting data with the Data Encryption algorithm, in Chipher Block Chaining mode and with an initialization vector implies that you should: Create three byte arrays, the first one for the password, the second one for the key and the third one for ...

Read More »

DES with CBC example

Bipartite Graph

With this example we are going to demonstrate how to encrypt data using the DES algorithm in CBC mode. In short, to encrypt/decrypt a String message with the Data Encryption Standard algorithm, in Chipher Block Chaining mode you should: Create a byte array to be used as initial input, a byte array to be used as a key and a ...

Read More »

Encrypt/Decrypt with with AES/ECB/PKCS7Padding

Bipartite Graph

In this example we shall show you how to encrypt/decrypt data with the AES/ECB/PKCS 7Padding. To encrypt data using the AES algorithm,in ECB mode and with PKCS7Padding one should perform the following steps: Create a byte array to be used as input to be encrypted and a byte array to be used as a key. Create a new SecretKeySpec for ...

Read More »

AWTPermission example

Bipartite Graph

This is an example of how to create an AWTPermission. AWTPermissions are permissions granted for the AWT Package of Java. In the AWTPermission API there is a list of all the possible AWTPermission target names, and for each one, there is a description of what the permission allows and a discussion of the risks of granting code the permission. In ...

Read More »

Signing a Java Object example

Bipartite Graph

With this example we are going to demonstrate how to sign a Java Object. In particular, we will use the Digital Signature Algorithm (DSA) to create a 1024-bit key pair and then sign a Serializable Object, using the key pair Signature. In short, to sign an Object in Java you should: Create a KeyPairGenerator for the DSA algorithm and initialize ...

Read More »

Get bytes of a key pair example

Bipartite Graph

In this example we shall show you how to get the bytes of a key pair in Java. To get the bytes of a key pair one should perform the following steps: Create a KeyPairGenerator for the DSA algorithm and initialize it with a 1024-bit key size. Generate the KeyPair, with the genKeyPair() API method of the KeyPairGenerator. Get the ...

Read More »

Generate Keys from DSA parameters example

Bipartite Graph

This is an example of how to generate keys from the DSA Parameters in Java. Using the DSA parameters to generate keys implies that you should: Create five BigInteger Objects, to be used as the DSA Parameters, the prime, the subPrime, the base and the private and public keys. Create a new KeyFactory for the DSA algorithm. Create a DSAPrivateKeySpec, ...

Read More »

Get all permissions granted to a loaded class example

Bipartite Graph

With this example we are going to demonstrate how to get all permissions granted to a loaded Class in Java. In short, to get the permissions granted to a Class that is loaded you should: Get the ProtectionDomain of the Class. Create a new ProtectionDomain, using the getProtectionDomain() API method of the Class. Create a PermissionCollection, by getting the permissions ...

Read More »

Check if a permission implies another permission example

Bipartite Graph

In this example we shall show you how to check if a permission to a file implies another permission. To check the permissions to a specific file one should perform the following steps: Create a new FilePermission with a given String as path and another given String as actions. Create a second FilePermission with a another String as path and ...

Read More »

Check read/write permission for a directory example

Bipartite Graph

This is an example of how to check read/write permission for a directory. Checking read/write permission for a directory implies that you should: Create a FilePermission for the pathname of the directory, and a comma-separated list of the actions granted on the directory. Invoke the checkPermission(Permission perm) API method of the AccessController, in order to check whether the access request ...

Read More »