java.com.ionic.sdk.cipher.aes.model.AesKeyGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ionic-sdk Show documentation
Show all versions of ionic-sdk Show documentation
The Ionic Java SDK provides an easy-to-use interface to the Ionic Platform.
package com.ionic.sdk.cipher.aes.model;
import com.ionic.sdk.agent.AgentSdk;
import com.ionic.sdk.cipher.aes.AesCipher;
import com.ionic.sdk.error.IonicException;
import javax.crypto.KeyGenerator;
/**
* Class encapsulating capability to generate symmetric cryptography keys.
*/
public class AesKeyGenerator {
/**
* Constructor.
*/
public AesKeyGenerator() {
}
/**
* Creates a new cryptographic key.
*
* @return a {@link AesKeyHolder} object containing the newly created key
* @throws IonicException on cryptography errors
*/
public final AesKeyHolder generate() throws IonicException {
final KeyGenerator keygenSymmetric = AgentSdk.getCrypto().getKeyGeneratorAes();
keygenSymmetric.init(AesCipher.KEY_BITS);
return new AesKeyHolder(keygenSymmetric.generateKey());
}
}