Home » security » Page 2

Tag Archives: security

Encrypt/Decrypt a file using DES

Bipartite Graph

In this example we shall show you how to encrypt/decrypt a file using DES. To encrypt and decrypt a file using the Data Encryption Standard Algorithm, one should perform the following steps: Create a KeyGenerator for the DES algorithm and generate a secret key. Create an IvParameterSpec object, which is an implementation of the AlgorithmParameterSpec Interface, a specification of cryptographic ...

Read More »

Calculate the CRC Sum of a file

Bipartite Graph

With this example we are going to demonstrate how to calculate the CRC Sum of a file. The Cyclic Redundancy Check is a good way to detect errors and changes to data. In short, in order to calculate the CRC-32 Sum of a file we implemented four different methods : The checksumInputStream(String filepath) method creates a FileInputStream by opening a ...

Read More »

Encrypt/Decrypt with salt

Bipartite Graph

This is an example of how to encrypt and decrypt using a salt. The salt is random data very often used in cryptography as additional input to a hash function. Doing encryption and decryption of a String with a salt implies that you should: Read an initial String. Generate random bytes to be placed in the salt. Create a sun.misc.BASE64Decoder ...

Read More »

Check message consistency using hash functions

Bipartite Graph

In this example we shall show you how to check message consistency using hash functions. We are using the java.security.MessageDigest Class, that provides the functionality of a message digest algorithm. It takes arbitrary-sized data and outputs a fixed-length hash value. To check the consistency of two messages using the MessageDigest hash function, one should perform the following steps: Create a ...

Read More »

SHA-1 hash function example

Bipartite Graph

With this example we are going to demonstrate how to make a SHA-1 hash function example. The Secure Hash Algorithm is a family of cryptographic functions. In short, to compute the hash value of a String with the SHA-1 algorithm, you should: Create a MessageDigest Object that implements the SHA-1 algorithm, using the getInstance(String algorithm) API method. Reset the MessageDigest ...

Read More »

Diffie-Helman key pair generation and parameters

Bipartite Graph

This is an example of how to generate key pairs with the Diffie-Helman algorithm. The DH algorithm is be used to generate private/public key pairs. The private key can be used to generate a digital signature for a document by the owner of the document. Then the public key can be used by the one who receives the document to ...

Read More »

Simple symmetric key encrypt/decrypt

Bipartite Graph

In this example we shall show you how to encrypt and decrypt using a symmetric key. In the case of a symmetric key, the same key is used to encrypt and decrypt the data. Because both parties have the same key, the decryption essentially is performed by reversing some part of the encryption process. To encrypt and decrypt a String ...

Read More »

PBE with a PBEParameterSpec example

Bipartite Graph

With this example we are going to demonstrate how to make PBE using a PBEParameterSpec. In short, to make a Password-Based Encryption using a PBEParameterSpec you should: Create three byte arrays, the first one from the String message to be encrypted, the second one to be used as a key and the third one to be used as an initialization ...

Read More »

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 ECB example

Bipartite Graph

In this example we shall show you how to encrypt data using the DES algorithm in ECB mode. To encrypt a String message with the Data Encryption algorithm in Electronic Code Book mode one should perform the following steps: Create a byte array from the initial String message, and a byte array to be used as a key. Create a ...

Read More »