public class Cryptor extends Object
| Modifier and Type | Method and Description |
|---|---|
String |
decrypt(String str)
Decrypt a (base-64 encoded) encrypted string
|
JSONObject |
decryptJSONObject(String str)
Decrypt a (base-64 encoded) encrypted JSON object literal.
|
Object |
decryptObject(Class baseType,
String str)
Decrypt and decode a (base-64 encoded) encrypted object serialized as a
JSON object literal.
|
String |
encrypt(String str)
Produce a (base-64 encoded) encrypted version of a string.
|
static String |
generateKey()
Generate a new, random key.
|
public Cryptor(String keyStr) throws IOException
keyStr - Base64-encoded symmetric key.IOException - if the key string is malformed.public String decrypt(String str) throws IOException
str - Encrypted string to be decrypted, as generated by the encrypt
method of this class.IOException - if the input string is malformed.public JSONObject decryptJSONObject(String str) throws IOException, SyntaxError
str - Encrypted string to be decrypted.IOException - if the input string is malformedSyntaxError - if the decrypted JSON literal is invalidpublic Object decryptObject(Class baseType, String str) throws IOException
baseType - The desired class of the resulting Java object. The
result will not necessarily be of this class, but will be assignable
to a variable of this class.str - Encrypted string to be decrypted.IOException - if the input string is malformedpublic String encrypt(String str)
str - String to be encryptedpublic static String generateKey()
Copyright © 2017. All rights reserved.